1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-04-20 03:07:12 +02:00
SqMod/vendor/POCO/Net/src/PartStore.cpp
Sandu Liviu Catalin 4a6bfc086c Major plugin refactor and cleanup.
Switched to POCO library for unified platform/library interface.
Deprecated the external module API. It was creating more problems than solving.
Removed most built-in libraries in favor of system libraries for easier maintenance.
Cleaned and secured code with help from static analyzers.
2021-01-30 08:51:39 +02:00

88 lines
1.1 KiB
C++

//
// PartStore.cpp
//
// Library: Net
// Package: Messages
// Module: PartStore
//
// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Net/PartStore.h"
#include "Poco/TemporaryFile.h"
#include "Poco/File.h"
#include "Poco/Exception.h"
namespace Poco {
namespace Net {
//
// PartStore
//
PartStore::PartStore(const std::string& mediaType): PartSource(mediaType)
{
}
PartStore::~PartStore()
{
}
//
// FilePartStore
//
FilePartStore::FilePartStore(const std::string& content, const std::string& mediaType, const std::string& filename):
PartStore(mediaType),
_filename(filename),
_path(TemporaryFile::tempName()),
_fstr(_path)
{
_fstr << content << std::flush;
_fstr.seekg(0, std::ios::beg);
}
FilePartStore::~FilePartStore()
{
try
{
_fstr.close();
File(_path).remove();
}
catch (...)
{
}
}
std::istream& FilePartStore::stream()
{
return _fstr;
}
const std::string& FilePartStore::filename() const
{
return _filename;
}
const std::string& FilePartStore::path() const
{
return _path;
}
} } // namespace Poco::Net