blob: 7bc07266c985deeb339b1dc4096c8bce3fe85d82 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/core/utils/FileSystemUtils.h>
#include <aws/core/platform/FileSystem.h>
namespace Aws
{
namespace Utils
{
static Aws::String ComputeTempFileName(const char* prefix, const char* suffix)
{
Aws::String prefixStr;
if (prefix)
{
prefixStr = prefix;
}
Aws::String suffixStr;
if (suffix)
{
suffixStr = suffix;
}
return prefixStr + Aws::FileSystem::CreateTempFilePath() + suffixStr;
}
TempFile::TempFile(const char* prefix, const char* suffix, std::ios_base::openmode openFlags) :
FStreamWithFileName(ComputeTempFileName(prefix, suffix).c_str(), openFlags)
{
}
TempFile::TempFile(const char* prefix, std::ios_base::openmode openFlags) :
FStreamWithFileName(ComputeTempFileName(prefix, nullptr).c_str(), openFlags)
{
}
TempFile::TempFile(std::ios_base::openmode openFlags) :
FStreamWithFileName(ComputeTempFileName(nullptr, nullptr).c_str(), openFlags)
{
}
TempFile::~TempFile()
{
Aws::FileSystem::RemoveFileIfExists(m_fileName.c_str());
}
}
}
|