mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 16:42:05 +00:00
28 lines
589 B
C++
28 lines
589 B
C++
|
#include <Disks/TemporaryFileOnDisk.h>
|
||
|
#include <Disks/IDisk.h>
|
||
|
#include <Poco/TemporaryFile.h>
|
||
|
|
||
|
|
||
|
namespace DB
|
||
|
{
|
||
|
|
||
|
TemporaryFileOnDisk::TemporaryFileOnDisk(const DiskPtr & disk_, const String & prefix_)
|
||
|
: disk(disk_)
|
||
|
{
|
||
|
String dummy_prefix = "a/";
|
||
|
filepath = Poco::TemporaryFile::tempName(dummy_prefix);
|
||
|
dummy_prefix += "tmp";
|
||
|
assert(filepath.starts_with(dummy_prefix));
|
||
|
filepath.replace(0, dummy_prefix.length(), prefix_);
|
||
|
}
|
||
|
|
||
|
TemporaryFileOnDisk::~TemporaryFileOnDisk()
|
||
|
{
|
||
|
#if 1
|
||
|
if (disk && !filepath.empty())
|
||
|
disk->removeRecursive(filepath);
|
||
|
#endif
|
||
|
}
|
||
|
|
||
|
}
|