ArmNN
 22.05
Filesystem.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 #if !defined(ARMNN_DISABLE_FILESYSTEM)
6 
8 
9 namespace armnnUtils
10 {
11 namespace Filesystem
12 {
13 
14 /**
15  * @brief Construct a temporary file name.
16  *
17  * Given a specified file name construct a path to that file in the
18  * system temporary directory. If the file already exists it is deleted. This
19  * could throw filesystem_error exceptions.
20  *
21  * @param fileName the file name required in the temporary directory.
22  * @return path consisting of system temporary directory and file name.
23  */
24 fs::path NamedTempFile(const char* fileName)
25 {
26  fs::path tmpDir = fs::temp_directory_path();
27  fs::path namedTempFile{tmpDir / fileName};
28  if (fs::exists(namedTempFile))
29  {
30  fs::remove(namedTempFile);
31  }
32  return namedTempFile;
33 }
34 
35 } // namespace armnnUtils
36 } // namespace Filesystem
37 
38 #endif // !defined(ARMNN_DISABLE_FILESYSTEM)
fs::path NamedTempFile(const char *fileName)
Returns a path to a file in the system temporary folder. If the file existed it will be deleted...
Definition: Filesystem.cpp:24