#define LLVM_SYSTEM_PATH_H
#include "llvm/System/TimeValue.h"
+#include "llvm/Support/raw_ostream.h"
#include <set>
#include <string>
#include <vector>
/// of the path, use the isValid method.
/// @param p The path to assign.
/// @brief Construct a Path from a string.
- explicit Path(const std::string& p) : path(p) {}
+ explicit Path(const std::string& p);
/// This constructor will accept a character range as a path. No checking
/// is done on this path to determine if it is valid. To determine
/// @param StrStart A pointer to the first character of the path name
/// @param StrLen The length of the path name at StrStart
/// @brief Construct a Path from a string.
- explicit Path(const char *StrStart, unsigned StrLen)
- : path(StrStart, StrStart+StrLen) {}
+ Path(const char *StrStart, unsigned StrLen);
/// @}
/// @name Operators
return *this;
}
+ /// Makes a copy of \p that to \p this.
+ /// @param \p that A std::string denoting the path
+ /// @returns \p this
+ /// @brief Assignment Operator
+ Path &operator=(const std::string &that);
+
/// Compares \p this Path with \p that Path for equality.
/// @returns true if \p this and \p that refer to the same thing.
/// @brief Equality Operator
- bool operator==(const Path &that) const {
- return 0 == path.compare(that.path);
- }
+ bool operator==(const Path &that) const;
/// Compares \p this Path with \p that Path for inequality.
/// @returns true if \p this and \p that refer to different things.
/// @brief Inequality Operator
- bool operator!=(const Path &that) const {
- return 0 != path.compare(that.path);
- }
+ bool operator!=(const Path &that) const;
/// 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.
/// the std::string::compare method.
/// @returns true if \p this path is lexicographically less than \p that.
/// @brief Less Than Operator
- bool operator<(const Path& that) const {
- return 0 > path.compare(that.path);
- }
+ bool operator<(const Path& that) const;
/// @}
/// @name Path Accessors
const char *c_str() const { return path.c_str(); }
/// size - Return the length in bytes of this path name.
- unsigned size() const { return path.size(); }
+ size_t size() const { return path.size(); }
/// empty - Returns true if the path is empty.
unsigned empty() const { return path.empty(); }
/// @brief Determine if the path is absolute.
bool isAbsolute() const;
+ /// This function determines if the path name is absolute, as opposed to
+ /// relative.
+ /// @brief Determine if the path is absolute.
+ static bool isAbsolute(const char *NameStart, unsigned NameLen);
+
/// This function opens the file associated with the path name provided by
/// the Path object and reads its magic number. If the magic number at the
/// start of the file matches \p magic, true is returned. In all other
/// @brief Make the current path name unique in the file system.
bool makeUnique( bool reuse_current /*= true*/, std::string* ErrMsg );
+ /// The current Path name is made absolute by prepending the
+ /// current working directory if necessary.
+ void makeAbsolute();
+
/// @}
/// @name Disk Mutators
/// @{
extern const char PathSeparator;
}
+inline raw_ostream& operator<<(raw_ostream& strm, const sys::Path& aPath) {
+ strm << aPath.toString();
+ return strm;
+}
+
+inline raw_ostream& operator<<(raw_ostream& strm,
+ const sys::PathWithStatus& aPath) {
+ strm << static_cast<const sys::Path&>(aPath);
+ return strm;
+}
+
std::ostream& operator<<(std::ostream& strm, const sys::Path& aPath);
inline std::ostream& operator<<(std::ostream& strm,
const sys::PathWithStatus& aPath) {