summaryrefslogtreecommitdiffstats
path: root/contrib/libs/poco/Net/src/FilePartSource.cpp
diff options
context:
space:
mode:
authorDevtools Arcadia <[email protected]>2022-02-07 18:08:42 +0300
committerDevtools Arcadia <[email protected]>2022-02-07 18:08:42 +0300
commit1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch)
treee26c9fed0de5d9873cce7e00bc214573dc2195b7 /contrib/libs/poco/Net/src/FilePartSource.cpp
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'contrib/libs/poco/Net/src/FilePartSource.cpp')
-rw-r--r--contrib/libs/poco/Net/src/FilePartSource.cpp87
1 files changed, 87 insertions, 0 deletions
diff --git a/contrib/libs/poco/Net/src/FilePartSource.cpp b/contrib/libs/poco/Net/src/FilePartSource.cpp
new file mode 100644
index 00000000000..afd3a01db70
--- /dev/null
+++ b/contrib/libs/poco/Net/src/FilePartSource.cpp
@@ -0,0 +1,87 @@
+//
+// FilePartSource.cpp
+//
+// Library: Net
+// Package: Messages
+// Module: FilePartSource
+//
+// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/Net/FilePartSource.h"
+#include "Poco/Path.h"
+#include "Poco/File.h"
+#include "Poco/Exception.h"
+
+
+using Poco::Path;
+using Poco::OpenFileException;
+
+
+namespace Poco {
+namespace Net {
+
+
+FilePartSource::FilePartSource(const std::string& path):
+ _path(path), _istr(path)
+{
+ Path p(path);
+ _filename = p.getFileName();
+ if (!_istr.good())
+ throw OpenFileException(path);
+}
+
+
+FilePartSource::FilePartSource(const std::string& path, const std::string& mediaType):
+ PartSource(mediaType),
+ _path(path),
+ _istr(path)
+{
+ Path p(path);
+ _filename = p.getFileName();
+ if (!_istr.good())
+ throw OpenFileException(path);
+}
+
+
+FilePartSource::FilePartSource(const std::string& path, const std::string& filename, const std::string& mediaType):
+ PartSource(mediaType),
+ _path(path),
+ _filename(filename),
+ _istr(path)
+{
+ Path p(path);
+ if (!_istr.good())
+ throw OpenFileException(path);
+}
+
+
+FilePartSource::~FilePartSource()
+{
+}
+
+
+std::istream& FilePartSource::stream()
+{
+ return _istr;
+}
+
+
+const std::string& FilePartSource::filename() const
+{
+ return _filename;
+}
+
+
+std::streamsize FilePartSource::getContentLength() const
+{
+ Poco::File p(_path);
+ return static_cast<std::streamsize>(p.getSize());
+}
+
+
+} } // namespace Poco::Net