LLVM API Documentation

llvm::sys::Path Class Reference

An abstraction for operating system paths. More...

#include <PathV1.h>

Inheritance diagram for llvm::sys::Path:
Inheritance graph
[legend]
Collaboration diagram for llvm::sys::Path:
Collaboration graph
[legend]

List of all members.

Public Member Functions

Operators
Pathoperator= (const Path &that)
 Assignment Operator.
Pathoperator= (StringRef that)
 Assignment Operator.
bool operator== (const Path &that) const
 Equality Operator.
bool operator!= (const Path &that) const
 Inequality Operator.
bool operator< (const Path &that) const
 Less Than Operator.
Path Accessors
bool isValid () const
 Determine if a path is syntactically valid or not.
bool isEmpty () const
 Determines if the path name is empty (invalid).
 LLVM_ATTRIBUTE_DEPRECATED (StringRef getLast() const, LLVM_PATH_DEPRECATED_MSG(path::filename))
 Returns the last component of the path name.
 LLVM_ATTRIBUTE_DEPRECATED (StringRef getBasename() const, LLVM_PATH_DEPRECATED_MSG(path::stem))
 Get the base name of the path.
 LLVM_ATTRIBUTE_DEPRECATED (StringRef getDirname() const, LLVM_PATH_DEPRECATED_MSG(path::parent_path))
 LLVM_ATTRIBUTE_DEPRECATED (StringRef getSuffix() const, LLVM_PATH_DEPRECATED_MSG(path::extension))
 Get the suffix of the path.
const char * c_str () const
 Returns the path as a C string.
const std::string & str () const
size_t size () const
 size - Return the length in bytes of this path name.
unsigned empty () const
 empty - Returns true if the path is empty.
Disk Accessors
 LLVM_ATTRIBUTE_DEPRECATED (bool isAbsolute() const, LLVM_PATH_DEPRECATED_MSG(path::is_absolute))
 Determine if the path is absolute.
 LLVM_ATTRIBUTE_DEPRECATED (static bool isAbsolute(const char *NameStart, unsigned NameLen), LLVM_PATH_DEPRECATED_MSG(path::is_absolute))
 Determine if the path is absolute.
 LLVM_ATTRIBUTE_DEPRECATED (bool hasMagicNumber(StringRef magic) const, LLVM_PATH_DEPRECATED_MSG(fs::has_magic))
 Determine if file has a specific magic number.
bool getMagicNumber (std::string &Magic, unsigned len) const
 Get the file's magic number.
bool isArchive () const
 Determine if the path references an archive file.
bool isBitcodeFile () const
 Determine if the path references a bitcode file.
bool isDynamicLibrary () const
 Determine if the path references a dynamic library.
bool isObjectFile () const
 Determine if the path references an object file.
 LLVM_ATTRIBUTE_DEPRECATED (bool exists() const, LLVM_PATH_DEPRECATED_MSG(fs::exists))
 Determines if the path is a file or directory in the file system.
 LLVM_ATTRIBUTE_DEPRECATED (bool isDirectory() const, LLVM_PATH_DEPRECATED_MSG(fs::is_directory))
 Determines if the path is a directory in the file system.
 LLVM_ATTRIBUTE_DEPRECATED (bool isSymLink() const, LLVM_PATH_DEPRECATED_MSG(fs::is_symlink))
 Determines if the path is a symlink in the file system.
bool canRead () const
 Determines if the path is a readable file or directory in the file system.
bool canWrite () const
 Determines if the path is a writable file or directory in the file system.
bool isRegularFile () const
 Determines if the file is a regular file.
bool canExecute () const
 Determines if the path is an executable file in the file system.
bool getDirectoryContents (std::set< Path > &paths, std::string *ErrMsg) const
 Build a list of directory's contents.
Path Mutators
void clear ()
 Make the path empty.
bool set (StringRef unverified_path)
 Set a full path from a StringRef.
bool eraseComponent ()
 Removes the last directory component of the Path.
bool appendComponent (StringRef component)
 Appends one path component to the Path.
void appendSuffix (StringRef suffix)
 Adds a period and the suffix to the end of the pathname.
bool eraseSuffix ()
 Remove the suffix from a path name.
bool makeUnique (bool reuse_current, std::string *ErrMsg)
 Make the current path name unique in the file system.
 LLVM_ATTRIBUTE_DEPRECATED (void makeAbsolute(), LLVM_PATH_DEPRECATED_MSG(fs::make_absolute))

Protected Attributes

Data
std::string path
 Storage for the path name.

Constructors

 LLVM_ATTRIBUTE_DEPRECATED (static Path GetRootDirectory(), LLVM_PATH_DEPRECATED_MSG(NOTHING))
 Path ()
 Construct an empty (and invalid) path.
 Path (const Path &that)
 Path (StringRef p)
 Construct a Path from a string.
 Path (const char *StrStart, unsigned StrLen)
 Construct a Path from a string.
static Path GetTemporaryDirectory (std::string *ErrMsg=0)
 Construct a path to an new, unique, existing temporary directory.
static void GetSystemLibraryPaths (std::vector< sys::Path > &Paths)
 Construct a path to the system library directory.
static void GetBitcodeLibraryPaths (std::vector< sys::Path > &Paths)
 Construct a list of directories in which bitcode could be found.
static Path FindLibrary (std::string &short_name)
 Find a library.
static Path GetUserHomeDirectory ()
 Construct a path to the current user's "home" directory.
static Path GetCurrentDirectory ()
 Returns the current working directory.
static StringRef GetEXESuffix ()
 Return the executable file suffix.
static StringRef GetDLLSuffix ()
 Return the dynamic link library suffix.
static Path GetMainExecutable (const char *argv0, void *MainAddr)

Disk Mutators

bool makeReadableOnDisk (std::string *ErrMsg=0)
 Make the file readable;.
bool makeWriteableOnDisk (std::string *ErrMsg=0)
 Make the file writable;.
bool makeExecutableOnDisk (std::string *ErrMsg=0)
 Make the file readable;.
bool setStatusInfoOnDisk (const FileStatus &SI, std::string *ErrStr=0) const
 Set the status information.
bool createDirectoryOnDisk (bool create_parents=false, std::string *ErrMsg=0)
 Create the directory this Path refers to.
bool createFileOnDisk (std::string *ErrMsg=0)
 Create the file this Path refers to.
bool createTemporaryFileOnDisk (bool reuse_current=false, std::string *ErrMsg=0)
 Create a unique temporary file.
bool renamePathOnDisk (const Path &newName, std::string *ErrMsg)
 Rename one file as another.
bool eraseFromDisk (bool destroy_contents=false, std::string *Err=0) const
 Removes the file or directory from the filesystem.
static const char * MapInFilePages (int FD, size_t FileSize, off_t Offset)
static void UnMapFilePages (const char *Base, size_t FileSize)

Detailed Description

An abstraction for operating system paths.

This class provides an abstraction for the path to a file or directory in the operating system's filesystem and provides various basic operations on it. Note that this class only represents the name of a path to a file or directory which may or may not be valid for a given machine's file system. The class is patterned after the java.io.File class with various extensions and several omissions (not relevant to LLVM). A Path object ensures that the path it encapsulates is syntactically valid for the operating system it is running on but does not ensure correctness for any particular file system. That is, a syntactically valid path might specify path components that do not exist in the file system and using such a Path to act on the file system could produce errors. There is one invalid Path value which is permitted: the empty path. The class should never allow a syntactically invalid non-empty path name to be assigned. Empty paths are required in order to indicate an error result in some situations. If the path is empty, the isValid operation will return false. All operations will fail if isValid is false. Operations that change the path will either return false if it would cause a syntactically invalid path name (in which case the Path object is left unchanged) or throw an std::string exception indicating the error. The methods are grouped into four basic categories: Path Accessors (provide information about the path without accessing disk), Disk Accessors (provide information about the underlying file or directory), Path Mutators (change the path information, not the disk), and Disk Mutators (change the disk file/directory referenced by the path). The Disk Mutator methods all have the word "disk" embedded in their method name to reinforce the notion that the operation modifies the file system.

Since:
1.4

Definition at line 91 of file PathV1.h.


Constructor & Destructor Documentation

llvm::sys::Path::Path ( ) [inline]

Construct an empty (and invalid) path.

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.

Definition at line 173 of file PathV1.h.

Referenced by FindLibrary().

llvm::sys::Path::Path ( const Path that) [inline]

Definition at line 174 of file PathV1.h.

llvm::sys::Path::Path ( StringRef  p) [explicit]

Construct a Path from a string.

This constructor will accept a char* or std::string as a path. No checking is done on this path to determine if it is valid. To determine validity of the path, use the isValid method.

Parameters:
pThe path to assign.
llvm::sys::Path::Path ( const char *  StrStart,
unsigned  StrLen 
)

Construct a Path from a string.

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 validity of the path, use the isValid method.

Parameters:
StrStartA pointer to the first character of the path name
StrLenThe length of the path name at StrStart

Member Function Documentation

bool llvm::sys::Path::appendComponent ( StringRef  component)

Appends one path component to the Path.

The component is added to the end of the Path if it is a legal name for the operating system. A directory separator will be added if needed.

Returns:
false if the path component could not be added.

Referenced by FindLibrary(), llvm::PrependMainExecutablePath(), and llvm::WriteGraph().

void Path::appendSuffix ( StringRef  suffix)

Adds a period and the suffix to the end of the pathname.

A period and the suffix are appended to the end of the pathname. When the suffix is empty, no action is performed.

Definition at line 208 of file Path.cpp.

References llvm::StringRef::empty(), and path.

Referenced by llvm::DisplayGraph(), FindLibrary(), and llvm::PrependMainExecutablePath().

const char* llvm::sys::Path::c_str ( ) const [inline]

Returns the path as a C string.

Obtain a 'C' string for the path name.

Returns:
a 'C' string containing the path name.

Definition at line 284 of file PathV1.h.

References path.

Referenced by llvm::DiffFilesWithTolerance(), llvm::DisplayGraph(), ExpandResponseFiles(), llvm::GetBitcodeSymbols(), llvm::Archive::mapToMemory(), llvm::WriteGraph(), llvm::Archive::writeMember(), and llvm::Archive::writeToDisk().

bool llvm::sys::Path::canExecute ( ) const

Determines if the path is an executable file in the file system.

This function determines if the path name references an executable file in the file system. This function checks for the existence and executability (by the current program) of the file.

Returns:
true if the pathname references an executable file.
bool llvm::sys::Path::canRead ( ) const

Determines if the path is a readable file or directory in the file system.

This function determines if the path name references a readable file or directory in the file system. This function checks for the existence and readability (by the current program) of the file or directory.

Returns:
true if the pathname references a readable file.

Referenced by getPathList().

bool llvm::sys::Path::canWrite ( ) const

Determines if the path is a writable file or directory in the file system.

This function determines if the path name references a writable file or directory in the file system. This function checks for the existence and writability (by the current program) of the file or directory.

Returns:
true if the pathname references a writable file.
void llvm::sys::Path::clear ( ) [inline]

Make the path empty.

The path name is cleared and becomes empty. This is an invalid path name but is the *only* invalid path name. This is provided so that path objects can be used to indicate the lack of a valid path being found.

Definition at line 437 of file PathV1.h.

References path.

Referenced by llvm::WriteGraph().

bool llvm::sys::Path::createDirectoryOnDisk ( bool  create_parents = false,
std::string *  ErrMsg = 0 
)

Create the directory this Path refers to.

This method attempts to create a directory in the file system with the same name as the Path object. The create_parents parameter controls whether intermediate directories are created or not. if create_parents is true, then an attempt will be made to create all intermediate directories, as needed. If create_parents is false, then only the final directory component of the Path name will be created. The created directory will have no entries.

Returns:
true if the directory could not be created, false otherwise
Parameters:
create_parentsDetermines whether non-existent directory components other than the last one (the "parents") are created or not.
ErrMsgOptional place to put error messages.
bool llvm::sys::Path::createFileOnDisk ( std::string *  ErrMsg = 0)

Create the file this Path refers to.

This method attempts to create a file in the file system with the same name as the Path object. The intermediate directories must all exist at the time this method is called. Use createDirectoriesOnDisk to accomplish that. The created file will be empty upon return from this function.

Returns:
true if the file could not be created, false otherwise.
Parameters:
ErrMsgOptional place to put error messages.
bool llvm::sys::Path::createTemporaryFileOnDisk ( bool  reuse_current = false,
std::string *  ErrMsg = 0 
)

Create a unique temporary file.

This is like createFile except that it creates a temporary file. A unique temporary file name is generated based on the contents of this before the call. The new name is assigned to this and the file is created. Note that this will both change the Path object and* create the corresponding file. This function will ensure that the newly generated temporary file name is unique in the file system.

Returns:
true if the file couldn't be created, false otherwise.
Parameters:
reuse_currentWhen set to true, this parameter indicates that if the current file name does not exist then it will be used without modification.
ErrMsgOptional place to put error messages

Referenced by llvm::Archive::writeToDisk().

unsigned llvm::sys::Path::empty ( ) const [inline]

empty - Returns true if the path is empty.

Definition at line 292 of file PathV1.h.

References path.

bool llvm::sys::Path::eraseComponent ( )

Removes the last directory component of the Path.

One path component is removed from the Path. If only one component is present in the path, the Path object becomes empty. If the Path object is empty, no change is made.

Returns:
false if the path component could not be removed.

Referenced by llvm::PrependMainExecutablePath().

bool llvm::sys::Path::eraseFromDisk ( bool  destroy_contents = false,
std::string *  Err = 0 
) const

Removes the file or directory from the filesystem.

This method attempts to destroy the file or directory named by the last component of the Path. If the Path refers to a directory and the destroy_contents is false, an attempt will be made to remove just the directory (the final Path component). If destroy_contents is true, an attempt will be made to remove the entire contents of the directory, recursively. If the Path refers to a file, the destroy_contents parameter is ignored.

Parameters:
destroy_contentsIndicates whether the contents of a destroyed
ErrAn optional string to receive an error message. directory should also be destroyed (recursively).
Returns:
false if the file/directory was destroyed, true on error.

Referenced by ExecGraphViewer(), and llvm::Archive::writeToDisk().

bool llvm::sys::Path::eraseSuffix ( )

Remove the suffix from a path name.

The suffix of the filename is erased. The suffix begins with and includes the last . character in the filename after the last directory separator and extends until the end of the name. If no . character is after the last directory separator, then the file name is left unchanged (i.e. it was already without a suffix) but the function returns false.

Returns:
false if there was no suffix to remove, true otherwise.

Referenced by FindLibrary().

Path Path::FindLibrary ( std::string &  short_name) [static]

Find a library.

Find the path to a library using its short name. Use the system dependent library paths to locate the library.

Definition at line 187 of file Path.cpp.

References appendComponent(), appendSuffix(), eraseSuffix(), GetSystemLibraryPaths(), isArchive(), isDynamicLibrary(), LTDL_SHLIB_EXT, and Path().

static void llvm::sys::Path::GetBitcodeLibraryPaths ( std::vector< sys::Path > &  Paths) [static]

Construct a list of directories in which bitcode could be found.

Construct a vector of sys::Path that contains the "standard" bitcode library paths suitable for linking into an llvm program. This function must* return the value of LLVM_LIB_SEARCH_PATH as well as the value of LLVM_LIBDIR. It also must provide the System library paths as returned by GetSystemLibraryPaths.

See also:
GetSystemLibraryPaths
static Path llvm::sys::Path::GetCurrentDirectory ( ) [static]

Returns the current working directory.

Construct a path to the current directory for the current process.

Returns:
The current working directory.
bool llvm::sys::Path::getDirectoryContents ( std::set< Path > &  paths,
std::string *  ErrMsg 
) const

Build a list of directory's contents.

This function builds a list of paths that are the names of the files and directories in a directory.

Returns:
true if an error occurs, true otherwise
Parameters:
pathsThe resulting list of file & directory names
ErrMsgOptional place to return an error message.
StringRef Path::GetDLLSuffix ( ) [static]

Return the dynamic link library suffix.

Return the suffix commonly used on file names that contain a shared object, shared archive, or dynamic link library. Such files are linked at runtime into a process and their code images are shared between processes.

Returns:
The dynamic link library suffix for the current platform.

Definition at line 203 of file Path.cpp.

References LTDL_SHLIB_EXT.

static StringRef llvm::sys::Path::GetEXESuffix ( ) [static]

Return the executable file suffix.

Return the suffix commonly used on file names that contain an executable.

Returns:
The executable file suffix for the current platform.

Referenced by llvm::PrependMainExecutablePath().

bool llvm::sys::Path::getMagicNumber ( std::string &  Magic,
unsigned  len 
) const

Get the file's magic number.

This function retrieves the first len bytes of the file associated with this. These bytes are returned as the "magic number" in the Magic parameter.

Returns:
true if the Path is a file and the magic number is retrieved, false otherwise.
static Path llvm::sys::Path::GetMainExecutable ( const char *  argv0,
void *  MainAddr 
) [static]

GetMainExecutable - Return the path to the main executable, given the value of argv[0] from program startup and the address of main itself. In extremis, this function may fail and return an empty path.

Referenced by llvm::PrependMainExecutablePath().

static void llvm::sys::Path::GetSystemLibraryPaths ( std::vector< sys::Path > &  Paths) [static]

Construct a path to the system library directory.

Construct a vector of sys::Path that contains the "standard" system library paths suitable for linking into programs.

Referenced by FindLibrary().

static Path llvm::sys::Path::GetTemporaryDirectory ( std::string *  ErrMsg = 0) [static]

Construct a path to an new, unique, existing temporary directory.

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.

Returns:
an invalid path (empty) on error
Parameters:
ErrMsgOptional place for an error message if an error occurs

Referenced by llvm::WriteGraph().

static Path llvm::sys::Path::GetUserHomeDirectory ( ) [static]

Construct a path to the current user's "home" directory.

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.

bool Path::isArchive ( ) const

Determine if the path references an archive file.

This function determines if the path name in the object references an archive file by looking at its magic number.

Returns:
true if the file starts with the magic number for an archive file.

Definition at line 156 of file Path.cpp.

References llvm::sys::fs::file_magic::archive, llvm::sys::fs::identify_magic(), and str().

Referenced by FindLibrary().

bool Path::isBitcodeFile ( ) const

Determine if the path references a bitcode file.

This function determines if the path name in the object references an LLVM Bitcode file by looking at its magic number.

Returns:
true if the file starts with the magic number for LLVM bitcode files.

Definition at line 216 of file Path.cpp.

References llvm::sys::fs::file_magic::bitcode, llvm::sys::fs::identify_magic(), and str().

bool Path::isDynamicLibrary ( ) const

Determine if the path references a dynamic library.

This function determines if the path name in the object references a native Dynamic Library (shared library, shared object) by looking at the file's magic number. The Path object must reference a file, not a directory.

Returns:
true if the file starts with the magic number for a native shared library.

Definition at line 164 of file Path.cpp.

References llvm::sys::fs::file_magic::elf_shared_object, llvm::sys::fs::identify_magic(), llvm::sys::fs::file_magic::macho_dynamically_linked_shared_lib, llvm::sys::fs::file_magic::macho_dynamically_linked_shared_lib_stub, llvm::sys::fs::file_magic::macho_fixed_virtual_memory_shared_lib, llvm::sys::fs::file_magic::pecoff_executable, and str().

Referenced by FindLibrary().

bool llvm::sys::Path::isEmpty ( ) const [inline]

Determines if the path name is empty (invalid).

This function determines if the contents of the path name are empty. That is, the path name has a zero length. This does NOT determine if if the file is empty. To get the length of the file itself, Use the PathWithStatus::getFileStatus() method and then the getSize() method on the returned FileStatus object.

Returns:
true iff the path is empty.

Definition at line 247 of file PathV1.h.

References path.

Referenced by llvm::PrependMainExecutablePath(), llvm::ViewGraph(), and llvm::WriteGraph().

bool Path::isObjectFile ( ) const

Determine if the path references an object file.

This function determines if the path name in the object references a native object file by looking at it's magic number. The term object file is defined as "an organized collection of separate, named sequences of binary data." This covers the obvious file formats such as COFF and ELF, but it also includes llvm ir bitcode, archives, libraries, etc...

Returns:
true if the file starts with the magic number for an object file.

Definition at line 179 of file Path.cpp.

References llvm::sys::fs::identify_magic(), str(), and llvm::sys::fs::file_magic::unknown.

bool llvm::sys::Path::isRegularFile ( ) const

Determines if the file is a regular file.

This function checks that what we're trying to work only on a regular file. Check for things like /dev/null, any block special file, or other things that aren't "regular" regular files.

Returns:
true if the file is S_ISREG.
bool llvm::sys::Path::isValid ( ) const

Determine if a path is syntactically valid or not.

This function will use an operating system specific algorithm to determine if the current value of 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.
llvm::sys::Path::LLVM_ATTRIBUTE_DEPRECATED ( static Path   GetRootDirectory(),
LLVM_PATH_DEPRECATED_MSG(NOTHING)   
)

Construct a path to the root directory of the file system. The root directory is a top level directory above which there are no more directories. For example, on UNIX, the root directory is /. On Windows it is file:///. Other operating systems may have different notions of what the root directory is or none at all. In that case, a consistent default root directory will be used.

llvm::sys::Path::LLVM_ATTRIBUTE_DEPRECATED ( StringRef getLast()  const,
LLVM_PATH_DEPRECATED_MSG(path::filename)   
)

Returns the last component of the path name.

This function returns the last component of the path name. The last component is the file or directory name occurring after the last directory separator. If no directory separator is present, the entire path name is returned (i.e. same as toString).

Returns:
StringRef containing the last component of the path name.
llvm::sys::Path::LLVM_ATTRIBUTE_DEPRECATED ( StringRef getBasename()  const,
LLVM_PATH_DEPRECATED_MSG(path::stem)   
)

Get the base name of the path.

This function strips off the path and suffix of the file or directory name and returns just the basename. For example /a/foo.bar would cause this function to return "foo".

Returns:
StringRef containing the basename of the path
llvm::sys::Path::LLVM_ATTRIBUTE_DEPRECATED ( StringRef getDirname()  const,
LLVM_PATH_DEPRECATED_MSG(path::parent_path)   
)

This function strips off the suffix of the path beginning with the path separator ('/' on Unix, '\' on Windows) and returns the result.

llvm::sys::Path::LLVM_ATTRIBUTE_DEPRECATED ( StringRef getSuffix()  const,
LLVM_PATH_DEPRECATED_MSG(path::extension)   
)

Get the suffix of the path.

This function strips off the path and basename(up to and including the last dot) of the file or directory name and returns just the suffix. For example /a/foo.bar would cause this function to return "bar".

Returns:
StringRef containing the suffix of the path
llvm::sys::Path::LLVM_ATTRIBUTE_DEPRECATED ( bool isAbsolute()  const,
LLVM_PATH_DEPRECATED_MSG(path::is_absolute)   
)

Determine if the path is absolute.

This function determines if the path name is absolute, as opposed to relative.

llvm::sys::Path::LLVM_ATTRIBUTE_DEPRECATED ( static bool   isAbsoluteconst char *NameStart, unsigned NameLen,
LLVM_PATH_DEPRECATED_MSG(path::is_absolute)   
)

Determine if the path is absolute.

This function determines if the path name is absolute, as opposed to relative.

llvm::sys::Path::LLVM_ATTRIBUTE_DEPRECATED ( bool hasMagicNumber(StringRef magic)  const,
LLVM_PATH_DEPRECATED_MSG(fs::has_magic)   
)

Determine if file has a specific magic number.

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 magic, true is returned. In all other cases (file not found, file not accessible, etc.) it returns false.

Returns:
true if the magic number of the file matches magic.
llvm::sys::Path::LLVM_ATTRIBUTE_DEPRECATED ( bool exists()  const,
LLVM_PATH_DEPRECATED_MSG(fs::exists)   
)

Determines if the path is a file or directory in the file system.

This function determines if the path name references an existing file or directory in the file system.

Returns:
true if the pathname references an existing file or directory.
llvm::sys::Path::LLVM_ATTRIBUTE_DEPRECATED ( bool isDirectory()  const,
LLVM_PATH_DEPRECATED_MSG(fs::is_directory)   
)

Determines if the path is a directory in the file system.

This function determines if the path name references an existing directory.

Returns:
true if the pathname references an existing directory.
llvm::sys::Path::LLVM_ATTRIBUTE_DEPRECATED ( bool isSymLink()  const,
LLVM_PATH_DEPRECATED_MSG(fs::is_symlink)   
)

Determines if the path is a symlink in the file system.

This function determines if the path name references an existing symbolic link.

Returns:
true if the pathname references an existing symlink.
llvm::sys::Path::LLVM_ATTRIBUTE_DEPRECATED ( void   makeAbsolute(),
LLVM_PATH_DEPRECATED_MSG(fs::make_absolute)   
)

The current Path name is made absolute by prepending the current working directory if necessary.

bool llvm::sys::Path::makeExecutableOnDisk ( std::string *  ErrMsg = 0)

Make the file readable;.

This method attempts to make the file referenced by the Path object available for execution so that the canExecute() method will return true.

bool llvm::sys::Path::makeReadableOnDisk ( std::string *  ErrMsg = 0)

Make the file readable;.

This method attempts to make the file referenced by the Path object available for reading so that the canRead() method will return true.

Referenced by llvm::Archive::writeToDisk().

bool llvm::sys::Path::makeUnique ( bool  reuse_current,
std::string *  ErrMsg 
)

Make the current path name unique in the file system.

The current Path name is made unique in the file system. Upon return, the Path will have been changed to make a unique file in the file system or it will not have been changed if the current path name is already unique.

Exceptions:
std::stringif an unrecoverable error occurs.

Referenced by llvm::WriteGraph().

bool llvm::sys::Path::makeWriteableOnDisk ( std::string *  ErrMsg = 0)

Make the file writable;.

This method attempts to make the file referenced by the Path object available for writing so that the canWrite() method will return true.

Referenced by llvm::Archive::writeToDisk().

static const char* llvm::sys::Path::MapInFilePages ( int  FD,
size_t  FileSize,
off_t  Offset 
) [static]

MapInFilePages - This is a low level system API to map in the file that is currently opened as FD into the current processes' address space for read only access. This function may return null on failure or if the system cannot provide the following constraints: 1) The pages must be valid after the FD is closed, until UnMapFilePages is called. 2) Any padding after the end of the file must be zero filled, if present. 3) The pages must be contiguous.

This API is not intended for general use, clients should use MemoryBuffer::getFile instead.

bool llvm::sys::Path::operator!= ( const Path that) const [inline]

Inequality Operator.

Compares this Path with that Path for inequality.

Returns:
true if this and that refer to different things.

Definition at line 217 of file PathV1.h.

bool Path::operator< ( const Path that) const

Less Than Operator.

Determines if this Path is less than 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 this path is lexicographically less than that.

Definition at line 36 of file Path.cpp.

References path.

Path& llvm::sys::Path::operator= ( const Path that) [inline]

Assignment Operator.

Makes a copy of that to this.

Returns:
this

Reimplemented in llvm::sys::PathWithStatus.

Definition at line 198 of file PathV1.h.

References path.

Path& llvm::sys::Path::operator= ( StringRef  that)

Assignment Operator.

Makes a copy of that to this.

Parameters:
thatA StringRef denoting the path
Returns:
this
bool Path::operator== ( const Path that) const

Equality Operator.

Compares this Path with that Path for equality.

Returns:
true if this and that refer to the same thing.

Definition at line 32 of file Path.cpp.

References path.

bool llvm::sys::Path::renamePathOnDisk ( const Path newName,
std::string *  ErrMsg 
)

Rename one file as another.

This method renames the file referenced by this as newName. The file referenced by this must exist. The file referenced by newName does not need to exist.

Returns:
true on error, false otherwise

Referenced by llvm::Archive::writeToDisk().

bool llvm::sys::Path::set ( StringRef  unverified_path)

Set a full path from a StringRef.

This method sets the Path object to unverified_path. This can fail if the unverified_path does not pass the syntactic checks of the isValid() method. If verification fails, the Path object remains unchanged and false is returned. Otherwise true is returned and the Path object takes on the path value of unverified_path

Returns:
true if the path was set, false otherwise.
Parameters:
unverified_pathThe path to be set in Path object.

Referenced by getPathList(), and llvm::Archive::parseMemberHeader().

bool llvm::sys::Path::setStatusInfoOnDisk ( const FileStatus SI,
std::string *  ErrStr = 0 
) const

Set the status information.

This method allows the last modified time stamp and permission bits to be set on the disk object referenced by the Path.

Exceptions:
std::stringif an error occurs.
Returns:
true on error.
size_t llvm::sys::Path::size ( ) const [inline]

size - Return the length in bytes of this path name.

Definition at line 289 of file PathV1.h.

References path.

Referenced by llvm::sys::path::const_iterator::operator++(), and llvm::sys::path::const_iterator::operator--().

const std::string& llvm::sys::Path::str ( ) const [inline]
static void llvm::sys::Path::UnMapFilePages ( const char *  Base,
size_t  FileSize 
) [static]

UnMapFilePages - Free pages mapped into the current process by MapInFilePages.

This API is not intended for general use, clients should use MemoryBuffer::getFile instead.


Member Data Documentation

std::string llvm::sys::Path::path [mutable, protected]

Storage for the path name.

Definition at line 612 of file PathV1.h.

Referenced by appendSuffix(), c_str(), clear(), empty(), isEmpty(), operator<(), operator=(), operator==(), size(), and str().


The documentation for this class was generated from the following files: