+ /// Construct a path to a unique temporary directory that is created in
+ /// a "standard" place for the operating system. The directory is
+ /// guaranteed to be created on exit from this function. If the directory
+ /// cannot be created, the function will throw an exception.
+ /// @throws std::string indicating why the directory could not be created.
+ /// @brief Constrct a path to an new, unique, existing temporary
+ /// directory.
+ static Path GetTemporaryDirectory();
+
+ /// Construct a path to the first system library directory. The
+ /// implementation of Path on a given platform must ensure that this
+ /// directory both exists and also contains standard system libraries
+ /// suitable for linking into programs.
+ /// @throws nothing
+ /// @brief Construct a path to the first system library directory
+ static Path GetSystemLibraryPath1();
+
+ /// Construct a path to the second system library directory. The
+ /// implementation of Path on a given platform must ensure that this
+ /// directory both exists and also contains standard system libraries
+ /// suitable for linking into programs. Note that the "second" system
+ /// library directory may or may not be different from the first.
+ /// @throws nothing
+ /// @brief Construct a path to the second system library directory
+ static Path GetSystemLibraryPath2();
+
+ /// Construct a path to the default LLVM configuration directory. The
+ /// implementation must ensure that this is a well-known (same on many
+ /// systems) directory in which llvm configuration files exist. For
+ /// example, on Unix, the /etc/llvm directory has been selected.
+ /// @throws nothing
+ /// @brief Construct a path to the default LLVM configuration directory
+ static Path GetLLVMDefaultConfigDir();
+
+ /// Construct a path to the LLVM installed configuration directory. The
+ /// implementation must ensure that this refers to the "etc" directory of
+ /// the LLVM installation. This is the location where configuration files
+ /// will be located for a particular installation of LLVM on a machine.
+ /// @throws nothing
+ /// @brief Construct a path to the LLVM installed configuration directory
+ static Path GetLLVMConfigDir();
+
+ /// Construct a path to the current user's home directory. The
+ /// implementation must use an operating system specific mechanism for
+ /// determining the user's home directory. For example, the environment
+ /// variable "HOME" could be used on Unix. If a given operating system
+ /// does not have the concept of a user's home directory, this static
+ /// constructor must provide the same result as GetRootDirectory.
+ /// @throws nothing
+ /// @brief Construct a path to the current user's "home" directory
+ static Path GetUserHomeDirectory();
+
+ /// This is one of the very few ways in which a path can be constructed
+ /// with a syntactically invalid name. The only *legal* invalid name is an
+ /// empty one. Other invalid names are not permitted. Empty paths are
+ /// provided so that they can be used to indicate null or error results in
+ /// other lib/System functionality.
+ /// @throws nothing
+ /// @brief Construct an empty (and invalid) path.
+ Path() : path() {}
+
+ /// This constructor will accept a std::string as a path but if verifies
+ /// that the path string has a legal syntax for the operating system on
+ /// which it is running. This allows a path to be taken in from outside
+ /// the program. However, if the path is not valid, the Path object will
+ /// be set to an empty string and an exception will be thrown.
+ /// @throws std::string if the path string is not legal.
+ /// @param unvalidated_path The path to verify and assign.
+ /// @brief Construct a Path from a string.
+ explicit Path(std::string unverified_path);
+
+ /// @}
+ /// @name Operators
+ /// @{
+ public:
+ /// Makes a copy of \p that to \p this.
+ /// @returns \p this
+ /// @throws nothing
+ /// @brief Assignment Operator
+ Path & operator = ( const Path & that ) {
+ path = that.path;
+ return *this;
+ }
+
+ /// Compares \p this Path with \p that Path for equality.
+ /// @returns true if \p this and \p that refer to the same thing.
+ /// @throws nothing
+ /// @brief Equality Operator
+ bool operator == (const Path& that) const {
+ return 0 == path.compare(that.path) ;
+ }
+
+ /// Compares \p this Path with \p that Path for inequality.
+ /// @returns true if \p this and \p that refer to different things.
+ /// @throws nothing
+ /// @brief Inequality Operator
+ bool operator !=( const Path & that ) const {
+ return 0 != path.compare( that.path );
+ }
+
+ /// Determines if \p this Path is less than \p that Path. This is required
+ /// so that Path objects can be placed into ordered collections (e.g.
+ /// std::map). The comparison is done lexicographically as defined by
+ /// the std::string::compare method.
+ /// @returns true if \p this path is lexicographically less than \p that.
+ /// @throws nothing
+ /// @brief Less Than Operator
+ bool operator< (const Path& that) const {
+ return 0 > path.compare( that.path );
+ }
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ /// This function will use an operating system specific algorithm to
+ /// determine if the current value of \p this is a syntactically valid
+ /// path name for the operating system. The path name does not need to
+ /// exist, validity is simply syntactical. Empty paths are always invalid.
+ /// @returns true iff the path name is syntactically legal for the
+ /// host operating system.
+ /// @brief Determine if a path is syntactically valid or not.
+ bool is_valid() const;
+
+ /// This function determines if the contents of the path name are
+ /// empty. That is, the path has a zero length.
+ /// @returns true iff the path is empty.
+ /// @brief Determines if the path name is empty (invalid).
+ bool is_empty() const { return path.empty(); }
+
+ /// This function determines if the path name in this object is intended
+ /// to reference a legal file name (as opposed to a directory name). This
+ /// function does not verify anything with the file system, it merely
+ /// determines if the syntax of the path represents a file name or not.
+ /// @returns true if this path name references a file.
+ /// @brief Determines if the path name references a file.
+ bool is_file() const;
+
+ /// This function determines if the path name in this object is intended
+ /// to reference a legal directory name (as opposed to a file name). This
+ /// function does not verify anything with the file system, it merely
+ /// determines if the syntax of the path represents a directory name or
+ /// not.
+ /// @returns true if the path name references a directory
+ /// @brief Determines if the path name references a directory.
+ bool is_directory() const;
+
+ /// This function determines if the path name in this object references
+ /// the root (top level directory) of the file system. The details of what
+ /// is considered the "root" may vary from system to system so this method
+ /// will do the necessary checking.
+ /// @returns true iff the path name references the root directory.
+ /// @brief Determines if the path references the root directory.
+ bool is_root_directory() const;
+
+ /// This function determines if the path name references an existing file
+ /// or directory in the file system. Unlike is_file and is_directory, this
+ /// function actually checks for the existence of the file or directory.