diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-07-05 19:56:49 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-07-05 19:56:49 +0000 |
commit | e11874f6c5e33f5c2d634bfd33e1ae67c93f9b74 (patch) | |
tree | c9879b53b51837fc0a035486e43a703a13915330 /include/llvm/Support/FileSystem.h | |
parent | fe3b2995aa38b25bada9fa2e850590b3988668b5 (diff) | |
download | llvm-e11874f6c5e33f5c2d634bfd33e1ae67c93f9b74.tar.gz llvm-e11874f6c5e33f5c2d634bfd33e1ae67c93f9b74.tar.bz2 llvm-e11874f6c5e33f5c2d634bfd33e1ae67c93f9b74.tar.xz |
Add a higher level createTemporaryFile function.
This function is inspired by clang's Driver::GetTemporaryPath. It hides the
pattern used for uniquing and requires simple file names that are always
placed in the system temporary directory.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185716 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/FileSystem.h')
-rw-r--r-- | include/llvm/Support/FileSystem.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/include/llvm/Support/FileSystem.h b/include/llvm/Support/FileSystem.h index 3244517644..d8f79ba69d 100644 --- a/include/llvm/Support/FileSystem.h +++ b/include/llvm/Support/FileSystem.h @@ -575,6 +575,22 @@ error_code unique_file(const Twine &model, int &result_fd, error_code unique_file(const Twine &Model, SmallVectorImpl<char> &ResultPath, bool MakeAbsolute = true); +/// @brief Create a file in the system temporary directory. +/// +/// The filename is of the form prefix-random_chars.suffix. Since the directory +/// is not know to the caller, Prefix and Suffix cannot have path separators. +/// The files are created with mode 0600. +/// +/// This should be used for things like a temporary .s that is removed after +/// running the assembler. +error_code createTemporaryFile(const Twine &Prefix, StringRef Suffix, + int &ResultFD, + SmallVectorImpl<char> &ResultPath); + +/// @brief Simpler version for clients that don't want an open file. +error_code createTemporaryFile(const Twine &Prefix, StringRef Suffix, + SmallVectorImpl<char> &ResultPath); + error_code createUniqueDirectory(const Twine &Prefix, SmallVectorImpl<char> &ResultPath); |