diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2015-12-30 11:46:15 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2015-12-30 11:46:15 +0000 |
commit | dd58ef019b700900793a1eb48b52123db01b654e (patch) | |
tree | fcfbb4df56a744f4ddc6122c50521dd3f1c5e196 /include/llvm/Support/FileSystem.h | |
parent | 2fe5752e3a7c345cdb59e869278d36af33c13fa4 (diff) |
Notes
Diffstat (limited to 'include/llvm/Support/FileSystem.h')
-rw-r--r-- | include/llvm/Support/FileSystem.h | 51 |
1 files changed, 33 insertions, 18 deletions
diff --git a/include/llvm/Support/FileSystem.h b/include/llvm/Support/FileSystem.h index a736c324f8aa..4733ddb77575 100644 --- a/include/llvm/Support/FileSystem.h +++ b/include/llvm/Support/FileSystem.h @@ -95,21 +95,21 @@ enum perms { }; // Helper functions so that you can use & and | to manipulate perms bits: -inline perms operator|(perms l , perms r) { - return static_cast<perms>( - static_cast<unsigned short>(l) | static_cast<unsigned short>(r)); +inline perms operator|(perms l, perms r) { + return static_cast<perms>(static_cast<unsigned short>(l) | + static_cast<unsigned short>(r)); } -inline perms operator&(perms l , perms r) { - return static_cast<perms>( - static_cast<unsigned short>(l) & static_cast<unsigned short>(r)); +inline perms operator&(perms l, perms r) { + return static_cast<perms>(static_cast<unsigned short>(l) & + static_cast<unsigned short>(r)); } inline perms &operator|=(perms &l, perms r) { - l = l | r; - return l; + l = l | r; + return l; } inline perms &operator&=(perms &l, perms r) { - l = l & r; - return l; + l = l & r; + return l; } inline perms operator~(perms x) { return static_cast<perms>(~static_cast<unsigned short>(x)); @@ -156,6 +156,7 @@ class file_status friend bool equivalent(file_status A, file_status B); file_type Type; perms Perms; + public: #if defined(LLVM_ON_UNIX) file_status() : fs_st_dev(0), fs_st_ino(0), fs_st_mtime(0), @@ -267,6 +268,20 @@ private: /// @brief Make \a path an absolute path. /// +/// Makes \a path absolute using the \a current_directory if it is not already. +/// An empty \a path will result in the \a current_directory. +/// +/// /absolute/path => /absolute/path +/// relative/../path => <current-directory>/relative/../path +/// +/// @param path A path that is modified to be an absolute path. +/// @returns errc::success if \a path has been made absolute, otherwise a +/// platform-specific error_code. +std::error_code make_absolute(const Twine ¤t_directory, + SmallVectorImpl<char> &path); + +/// @brief Make \a path an absolute path. +/// /// Makes \a path absolute using the current directory if it is not already. An /// empty \a path will result in the current directory. /// @@ -285,7 +300,8 @@ std::error_code make_absolute(SmallVectorImpl<char> &path); /// specific error_code. If IgnoreExisting is false, also returns /// error if the directory already existed. std::error_code create_directories(const Twine &path, - bool IgnoreExisting = true); + bool IgnoreExisting = true, + perms Perms = owner_all | group_all); /// @brief Create the directory in path. /// @@ -293,7 +309,8 @@ std::error_code create_directories(const Twine &path, /// @returns errc::success if is_directory(path), otherwise a platform /// specific error_code. If IgnoreExisting is false, also returns /// error if the directory already existed. -std::error_code create_directory(const Twine &path, bool IgnoreExisting = true); +std::error_code create_directory(const Twine &path, bool IgnoreExisting = true, + perms Perms = owner_all | group_all); /// @brief Create a link from \a from to \a to. /// @@ -375,9 +392,7 @@ inline bool exists(const Twine &Path) { /// /// @param Path Input path. /// @returns True if we can execute it, false otherwise. -inline bool can_execute(const Twine &Path) { - return !access(Path, AccessMode::Execute); -} +bool can_execute(const Twine &Path); /// @brief Can we write this file? /// @@ -531,15 +546,15 @@ std::error_code status_known(const Twine &path, bool &result); /// /// Generates a unique path suitable for a temporary file and then opens it as a /// file. The name is based on \a model with '%' replaced by a random char in -/// [0-9a-f]. If \a model is not an absolute path, a suitable temporary -/// directory will be prepended. +/// [0-9a-f]. If \a model is not an absolute path, the temporary file will be +/// created in the current directory. /// /// Example: clang-%%-%%-%%-%%-%%.s => clang-a0-b1-c2-d3-e4.s /// /// This is an atomic operation. Either the file is created and opened, or the /// file system is left untouched. /// -/// The intendend use is for files that are to be kept, possibly after +/// The intended use is for files that are to be kept, possibly after /// renaming them. For example, when running 'clang -c foo.o', the file can /// be first created as foo-abc123.o and then renamed. /// |