From 7b3392326c40c3c20697816acae597ba7b3144eb Mon Sep 17 00:00:00 2001
From: dim <dim@FreeBSD.org>
Date: Thu, 20 Oct 2011 21:10:27 +0000
Subject: Vendor import of llvm release_30 branch r142614:
 http://llvm.org/svn/llvm-project/llvm/branches/release_30@142614

---
 include/llvm/Support/FileSystem.h | 162 ++++----------------------------------
 1 file changed, 17 insertions(+), 145 deletions(-)

(limited to 'include/llvm/Support/FileSystem.h')

diff --git a/include/llvm/Support/FileSystem.h b/include/llvm/Support/FileSystem.h
index 4f013f8..a868e5f 100644
--- a/include/llvm/Support/FileSystem.h
+++ b/include/llvm/Support/FileSystem.h
@@ -201,30 +201,6 @@ error_code rename(const Twine &from, const Twine &to);
 ///          platform specific error_code.
 error_code resize_file(const Twine &path, uint64_t size);
 
-/// @brief Make file readable.
-///
-/// @param path Input path.
-/// @param value If true, make readable, else, make unreadable.
-/// @results errc::success if readability has been successfully set, otherwise a
-///          platform specific error_code.
-error_code set_read(const Twine &path, bool value);
-
-/// @brief Make file writeable.
-///
-/// @param path Input path.
-/// @param value If true, make writeable, else, make unwriteable.
-/// @results errc::success if writeability has been successfully set, otherwise
-///          a platform specific error_code.
-error_code set_write(const Twine &path, bool value);
-
-/// @brief Make file executable.
-///
-/// @param path Input path.
-/// @param value If true, make executable, else, make unexecutable.
-/// @results errc::success if executability has been successfully set, otherwise
-///          a platform specific error_code.
-error_code set_execute(const Twine &path, bool value);
-
 /// @}
 /// @name Physical Observers
 /// @{
@@ -245,6 +221,13 @@ bool exists(file_status status);
 ///          platform specific error_code.
 error_code exists(const Twine &path, bool &result);
 
+/// @brief Simpler version of exists for clients that don't need to
+///        differentiate between an error and false.
+inline bool exists(const Twine &path) {
+  bool result;
+  return !exists(path, result) && result;
+}
+
 /// @brief Do file_status's represent the same thing?
 ///
 /// @param A Input file_status.
@@ -289,15 +272,6 @@ bool is_directory(file_status status);
 ///          platform specific error_code.
 error_code is_directory(const Twine &path, bool &result);
 
-/// @brief Is path an empty file?
-///
-/// @param path Input path.
-/// @param result Set to true if \a path is a an empty file, false if it is not.
-///               Undefined otherwise.
-/// @results errc::success if result has been successfully set, otherwise a
-///          platform specific error_code.
-error_code is_empty(const Twine &path, bool &result);
-
 /// @brief Does status represent a regular file?
 ///
 /// @param status A file_status previously returned from status.
@@ -346,40 +320,6 @@ bool is_symlink(file_status status);
 ///          platform specific error_code.
 error_code is_symlink(const Twine &path, bool &result);
 
-/// @brief Get last write time without changing it.
-///
-/// @param path Input path.
-/// @param result Set to the last write time (UNIX time) of \a path if it
-///               exists.
-/// @results errc::success if result has been successfully set, otherwise a
-///          platform specific error_code.
-error_code last_write_time(const Twine &path, std::time_t &result);
-
-/// @brief Set last write time.
-///
-/// @param path Input path.
-/// @param value Time to set (UNIX time) \a path's last write time to.
-/// @results errc::success if result has been successfully set, otherwise a
-///          platform specific error_code.
-error_code set_last_write_time(const Twine &path, std::time_t value);
-
-/// @brief Read a symlink's value.
-///
-/// @param path Input path.
-/// @param result Set to the value of the symbolic link \a path.
-/// @results errc::success if result has been successfully set, otherwise a
-///          platform specific error_code.
-error_code read_symlink(const Twine &path, SmallVectorImpl<char> &result);
-
-/// @brief Get disk space usage information.
-///
-/// @param path Input path.
-/// @param result Set to the capacity, free, and available space on the device
-///               \a path is on.
-/// @results errc::success if result has been successfully set, otherwise a
-///          platform specific error_code.
-error_code disk_space(const Twine &path, space_info &result);
-
 /// @brief Get file status as if by POSIX stat().
 ///
 /// @param path Input path.
@@ -402,16 +342,6 @@ bool status_known(file_status s);
 ///          platform specific error_code.
 error_code status_known(const Twine &path, bool &result);
 
-/// @brief Get file status as if by POSIX lstat().
-///
-/// Does not resolve symlinks.
-///
-/// @param path Input path.
-/// @param result Set to the file status.
-/// @results errc::success if result has been successfully set, otherwise a
-///          platform specific error_code.
-error_code symlink_status(const Twine &path, file_status &result);
-
 /// @brief Generate a unique path and open it as a file.
 ///
 /// Generates a unique path suitable for a temporary file and then opens it as a
@@ -427,10 +357,13 @@ error_code symlink_status(const Twine &path, file_status &result);
 /// @param model Name to base unique path off of.
 /// @param result_fs Set to the opened file's file descriptor.
 /// @param result_path Set to the opened file's absolute path.
+/// @param makeAbsolute If true and @model is not an absolute path, a temp
+///        directory will be prepended.
 /// @results errc::success if result_{fd,path} have been successfully set,
 ///          otherwise a platform specific error_code.
 error_code unique_file(const Twine &model, int &result_fd,
-                             SmallVectorImpl<char> &result_path);
+                             SmallVectorImpl<char> &result_path,
+                             bool makeAbsolute = true);
 
 /// @brief Canonicalize path.
 ///
@@ -472,60 +405,6 @@ error_code get_magic(const Twine &path, uint32_t len,
 ///          platform specific error_code.
 error_code identify_magic(const Twine &path, LLVMFileType &result);
 
-/// @brief Is file bitcode?
-///
-/// @param path Input path.
-/// @param result Set to true if \a path is a bitcode file, false if it is not,
-///               undefined otherwise.
-/// @results errc::success if result has been successfully set, otherwise a
-///          platform specific error_code.
-error_code is_bitcode(const Twine &path, bool &result);
-
-/// @brief Is file a dynamic library?
-///
-/// @param path Input path.
-/// @param result Set to true if \a path is a dynamic library, false if it is
-///               not, undefined otherwise.
-/// @results errc::success if result has been successfully set, otherwise a
-///          platform specific error_code.
-error_code is_dynamic_library(const Twine &path, bool &result);
-
-/// @brief Is an object file?
-///
-/// @param path Input path.
-/// @param result Set to true if \a path is an object file, false if it is not,
-///               undefined otherwise.
-/// @results errc::success if result has been successfully set, otherwise a
-///          platform specific error_code.
-error_code is_object_file(const Twine &path, bool &result);
-
-/// @brief Can file be read?
-///
-/// @param path Input path.
-/// @param result Set to true if \a path is readable, false it it is not,
-///               undefined otherwise.
-/// @results errc::success if result has been successfully set, otherwise a
-///          platform specific error_code.
-error_code can_read(const Twine &path, bool &result);
-
-/// @brief Can file be written?
-///
-/// @param path Input path.
-/// @param result Set to true if \a path is writeable, false it it is not,
-///               undefined otherwise.
-/// @results errc::success if result has been successfully set, otherwise a
-///          platform specific error_code.
-error_code can_write(const Twine &path, bool &result);
-
-/// @brief Can file be executed?
-///
-/// @param path Input path.
-/// @param result Set to true if \a path is executable, false it it is not,
-///               undefined otherwise.
-/// @results errc::success if result has been successfully set, otherwise a
-///          platform specific error_code.
-error_code can_execute(const Twine &path, bool &result);
-
 /// @brief Get library paths the system linker uses.
 ///
 /// @param result Set to the list of system library paths.
@@ -569,35 +448,28 @@ error_code GetMainExecutable(const char *argv0, void *MainAddr,
 /// @{
 
 /// directory_entry - A single entry in a directory. Caches the status either
-/// from the result of the iteration syscall, or the first time status or
-/// symlink_status is called.
+/// from the result of the iteration syscall, or the first time status is
+/// called.
 class directory_entry {
   std::string Path;
   mutable file_status Status;
-  mutable file_status SymlinkStatus;
 
 public:
-  explicit directory_entry(const Twine &path, file_status st = file_status(),
-                                       file_status symlink_st = file_status())
+  explicit directory_entry(const Twine &path, file_status st = file_status())
     : Path(path.str())
-    , Status(st)
-    , SymlinkStatus(symlink_st) {}
+    , Status(st) {}
 
   directory_entry() {}
 
-  void assign(const Twine &path, file_status st = file_status(),
-                          file_status symlink_st = file_status()) {
+  void assign(const Twine &path, file_status st = file_status()) {
     Path = path.str();
     Status = st;
-    SymlinkStatus = symlink_st;
   }
 
-  void replace_filename(const Twine &filename, file_status st = file_status(),
-                              file_status symlink_st = file_status());
+  void replace_filename(const Twine &filename, file_status st = file_status());
 
   const std::string &path() const { return Path; }
   error_code status(file_status &result) const;
-  error_code symlink_status(file_status &result) const;
 
   bool operator==(const directory_entry& rhs) const { return Path == rhs.Path; }
   bool operator!=(const directory_entry& rhs) const { return !(*this == rhs); }
-- 
cgit v1.1