2019-10-01 18:51:33 +00:00
|
|
|
#include <Common/filesystemHelpers.h>
|
|
|
|
#include <Poco/File.h>
|
|
|
|
#include <Poco/Path.h>
|
2019-10-05 19:25:31 +00:00
|
|
|
#include <Poco/Version.h>
|
2019-10-01 18:51:33 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2019-10-05 19:25:31 +00:00
|
|
|
bool enoughSpaceInDirectory(const std::string & path [[maybe_unused]], size_t data_size [[maybe_unused]])
|
2019-10-01 18:51:33 +00:00
|
|
|
{
|
2019-10-05 19:25:31 +00:00
|
|
|
#if POCO_VERSION >= 0x01090000
|
2019-10-01 18:51:33 +00:00
|
|
|
auto free_space = Poco::File(path).freeSpace();
|
|
|
|
if (data_size > free_space)
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<TemporaryFile> createTemporaryFile(const std::string & path)
|
|
|
|
{
|
|
|
|
Poco::File(path).createDirectories();
|
|
|
|
|
|
|
|
/// NOTE: std::make_shared cannot use protected constructors
|
|
|
|
return std::make_unique<TemporaryFile>(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|