diff options
author | orivej <orivej@yandex-team.ru> | 2022-02-10 16:44:49 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:49 +0300 |
commit | 718c552901d703c502ccbefdfc3c9028d608b947 (patch) | |
tree | 46534a98bbefcd7b1f3faa5b52c138ab27db75b7 /contrib/libs/poco/Foundation/src/FileStreamFactory.cpp | |
parent | e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (diff) | |
download | ydb-718c552901d703c502ccbefdfc3c9028d608b947.tar.gz |
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/poco/Foundation/src/FileStreamFactory.cpp')
-rw-r--r-- | contrib/libs/poco/Foundation/src/FileStreamFactory.cpp | 128 |
1 files changed, 64 insertions, 64 deletions
diff --git a/contrib/libs/poco/Foundation/src/FileStreamFactory.cpp b/contrib/libs/poco/Foundation/src/FileStreamFactory.cpp index 472559c95a..4e344b5e6f 100644 --- a/contrib/libs/poco/Foundation/src/FileStreamFactory.cpp +++ b/contrib/libs/poco/Foundation/src/FileStreamFactory.cpp @@ -1,64 +1,64 @@ -// -// FileStreamFactory.cpp -// -// Library: Foundation -// Package: URI -// Module: FileStreamFactory -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#include "Poco/FileStreamFactory.h" -#include "Poco/URI.h" -#include "Poco/Path.h" -#include "Poco/File.h" -#include "Poco/Exception.h" -#include "Poco/FileStream.h" - - -namespace Poco { - - -FileStreamFactory::FileStreamFactory() -{ -} - - -FileStreamFactory::~FileStreamFactory() -{ -} - - -std::istream* FileStreamFactory::open(const URI& uri) -{ - poco_assert (uri.isRelative() || uri.getScheme() == "file"); - - std::string uriPath = uri.getPath(); - if (uriPath.substr(0, 2) == "./") - uriPath.erase(0, 2); - Path p(uriPath, Path::PATH_UNIX); - p.setNode(uri.getHost()); - return open(p); -} - - -std::istream* FileStreamFactory::open(const Path& path) -{ - File file(path); - if (!file.exists()) throw FileNotFoundException(path.toString()); - - FileInputStream* istr = new FileInputStream(path.toString(), std::ios::binary); - if (!istr->good()) - { - delete istr; - throw OpenFileException(path.toString()); - } - return istr; -} - - -} // namespace Poco +// +// FileStreamFactory.cpp +// +// Library: Foundation +// Package: URI +// Module: FileStreamFactory +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#include "Poco/FileStreamFactory.h" +#include "Poco/URI.h" +#include "Poco/Path.h" +#include "Poco/File.h" +#include "Poco/Exception.h" +#include "Poco/FileStream.h" + + +namespace Poco { + + +FileStreamFactory::FileStreamFactory() +{ +} + + +FileStreamFactory::~FileStreamFactory() +{ +} + + +std::istream* FileStreamFactory::open(const URI& uri) +{ + poco_assert (uri.isRelative() || uri.getScheme() == "file"); + + std::string uriPath = uri.getPath(); + if (uriPath.substr(0, 2) == "./") + uriPath.erase(0, 2); + Path p(uriPath, Path::PATH_UNIX); + p.setNode(uri.getHost()); + return open(p); +} + + +std::istream* FileStreamFactory::open(const Path& path) +{ + File file(path); + if (!file.exists()) throw FileNotFoundException(path.toString()); + + FileInputStream* istr = new FileInputStream(path.toString(), std::ios::binary); + if (!istr->good()) + { + delete istr; + throw OpenFileException(path.toString()); + } + return istr; +} + + +} // namespace Poco |