LLVM API Documentation

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

llvm::sys::Path Class Reference

An abstraction for operating system paths. More...

#include <Path.h>

Collaboration diagram for llvm::sys::Path:

Collaboration graph
[legend]
List of all members.

Constructors

 Path ()
 Construct an empty (and invalid) path.
 Path (std::string unverified_path)
 Construct a Path from a string.
static Path GetRootDirectory ()
static Path GetTemporaryDirectory ()
 Constrct a path to an new, unique, existing temporary directory.
static Path GetLibraryPath (const std::string &basename, const std::vector< std::string > &LibPaths)
 Locate a library in a platform specific manner.
static Path GetSystemLibraryPath1 ()
 Construct a path to the first system library directory.
static Path GetSystemLibraryPath2 ()
 Construct a path to the second system library directory.
static Path GetLLVMDefaultConfigDir ()
 Construct a path to the default LLVM configuration directory.
static Path GetLLVMConfigDir ()
 Construct a path to the LLVM installed configuration directory.
static Path GetUserHomeDirectory ()
 Construct a path to the current user's "home" directory.
static std::string GetDLLSuffix ()
 Return the dynamic link library suffix.

Public Member Functions

Operators
Pathoperator= (const Path &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.
Accessors
bool isValid () const
 Determine if a path is syntactically valid or not.
bool isEmpty () const
 Determines if the path name is empty (invalid).
bool isFile () const
 Determines if the path name references a file.
bool isDirectory () const
 Determines if the path name references a directory.
bool isRootDirectory () const
 Determines if the path references the root directory.
bool hasMagicNumber (const std::string &magic) const
 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 isBytecodeFile () const
 Determine if the path references a bytecode file.
bool exists () const
 Determines if the path is a file or directory in the file system.
bool readable () const
 Determines if the path is a readable file or directory in the file system.
bool writable () const
 Determines if the path is a writable file or directory in the file system.
bool executable () const
 Determines if the path is an executable file in the file system.
std::string get () const
 Returns the path as a std::string.
std::string getLast () const
 Returns the last component of the path name.
std::string getBasename () const
 Get the base name of the path.
bool getDirectoryContents (std::set< Path > &paths) const
 Build a list of directory's contents.
const char *const c_str () const
 Returns the path as a C string.
Mutators
void clear ()
void getStatusInfo (StatusInfo &info) const
 Get file status.
bool setDirectory (const std::string &unverified_path)
 Set a full path from a std::string.
bool setFile (const std::string &unverified_path)
 Set a full path from a std::string.
bool appendDirectory (const std::string &dirname)
 Adds the name of a directory to a Path.
bool elideDirectory ()
 Removes the last directory component of the Path.
bool appendFile (const std::string &filename)
 Appends the name of a file.
bool elideFile ()
 Removes the last file component of the path.
bool appendSuffix (const std::string &suffix)
 Adds a period and the suffix to the end of the pathname.
bool elideSuffix ()
 Remove the suffix from a path name.
bool createDirectory (bool create_parents=false)
 Create the directory this Path refers to.
bool createFile ()
 Create the file this Path refers to.
bool createTemporaryFile ()
 Create a unique temporary file.
bool destroyDirectory (bool destroy_contents=false)
 Removes the file or directory from the filesystem.
bool destroyFile ()
 Destroy the file this Path refers to.
bool renameFile (const Path &newName)
 Rename one file as another.
bool setStatusInfo (const StatusInfo &si) const
 Set file times and mode.

Classes

struct  StatusInfo
 File status structure. More...

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. A Path ensures that the name it encapsulates is syntactical valid for the operating system it is running on but does not ensure correctness for any particular file system. A Path either references a file or a directory and the distinction is consistently maintained. Most operations on the class have invariants that require the Path object to be either a file path or a directory path, but not both. Those operations will also leave the object as either a file path or object path. There is exactly one invalid Path which is the empty path. The class should never allow any other syntactically invalid non-empty path name to be assigned. Empty paths are required in order to indicate an error result. 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.

Since:
1.4

Definition at line 46 of file Path.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.

Exceptions:
nothing 

Definition at line 159 of file Path.h.

Referenced by GetLLVMDefaultConfigDir(), GetSystemLibraryPath1(), and GetSystemLibraryPath2().

llvm::sys::Path::Path std::string  unverified_path  )  [explicit]
 

Construct a Path from a string.

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.

Exceptions:
std::string if the path string is not legal.
Parameters:
unverified_path The path to verify and assign.

Definition at line 31 of file Unix/Path.cpp.

References ThrowErrno().


Member Function Documentation

bool llvm::sys::Path::appendDirectory const std::string &  dirname  ) 
 

Adds the name of a directory to a Path.

The dirname is added to the end of the Path if it is a legal directory name for the operating system. The precondition for this function is that the Path must reference a directory name (i.e. isDirectory() returns true).

Parameters:
dirname A string providing the directory name to be added to the end of the path.
Returns:
false if the directory name could not be added
Exceptions:
nothing 

Definition at line 331 of file Unix/Path.cpp.

References isFile(), isValid(), and path.

bool llvm::sys::Path::appendFile const std::string &  filename  ) 
 

Appends the name of a file.

The filename is added to the end of the Path if it is a legal directory name for the operating system. The precondition for this function is that the Path reference a directory name (i.e. isDirectory() returns true).

Exceptions:
nothing 
Returns:
false if the file name could not be added.

Definition at line 360 of file Unix/Path.cpp.

References isDirectory(), isValid(), and path.

Referenced by llvm::sys::Program::FindProgramByName(), llvm::sys::IsLibrary(), and llvm::IsLibrary().

bool llvm::sys::Path::appendSuffix const std::string &  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. The precondition for this function is that the Path reference a file name (i.e. isFile() returns true). If the Path is not a file, no action is taken and the function returns false. If the path would become invalid for the host operating system, false is returned.

Returns:
false if the suffix could not be added, true if it was.
Exceptions:
nothing 

Definition at line 384 of file Unix/Path.cpp.

References isDirectory(), isValid(), and path.

Referenced by llvm::sys::IsLibrary(), and llvm::IsLibrary().

const char* const 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 353 of file Path.h.

Referenced by llvm::sys::Program::ExecuteAndWait(), renameFile(), and llvm::Archive::writeToDisk().

void llvm::sys::Path::clear  )  [inline]
 

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 363 of file Path.h.

Referenced by GetLibraryPath(), llvm::sys::IsLibrary(), and llvm::IsLibrary().

bool llvm::sys::Path::createDirectory bool  create_parents = false  ) 
 

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. 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:
false if the Path does not reference a directory, true otherwise.
Parameters:
create_parents Determines whether non-existent directory components other than the last one (the "parents") are created or not.
Exceptions:
std::string if an error occurs.

Definition at line 412 of file Unix/Path.cpp.

References isDirectory(), llvm::next(), and ThrowErrno().

bool llvm::sys::Path::createFile  ) 
 

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 createDirectories to accomplish that. The created file will be empty upon return from this function.

Returns:
false if the Path does not reference a file, true otherwise.
Exceptions:
std::string if an error occurs.

Definition at line 453 of file Unix/Path.cpp.

References isFile(), and ThrowErrno().

bool llvm::Path::createTemporaryFile  ) 
 

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.

Exceptions:
std::string if there is an error

Definition at line 467 of file Unix/Path.cpp.

References isFile(), and ThrowErrno().

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

bool llvm::sys::Path::destroyDirectory bool  destroy_contents = false  ) 
 

Removes the file or directory from the filesystem.

This method attempts to destroy the directory named by the last in the Path name. If remove_contents is false, an attempt will be made to remove just the directory that this Path object refers to (the final Path component). If remove_contents is true, an attempt will be made to remove the entire contents of the directory, recursively.

Parameters:
destroy_contents Indicates whether the contents of a destroyed directory should also be destroyed (recursively).
Returns:
false if the Path does not refer to a directory, true otherwise.
Exceptions:
std::string if there is an error.

Definition at line 486 of file Unix/Path.cpp.

References exists(), isDirectory(), and ThrowErrno().

bool llvm::sys::Path::destroyFile  ) 
 

Destroy the file this Path refers to.

This method attempts to destroy the file named by the last item in the Path name.

Returns:
false if the Path does not refer to a file, true otherwise.
Exceptions:
std::string if there is an error.

Definition at line 514 of file Unix/Path.cpp.

References isFile(), and ThrowErrno().

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

bool llvm::sys::Path::elideDirectory  ) 
 

Removes the last directory component of the Path.

One directory component is removed from the Path name. The Path must refer to a non-root directory name (i.e. isDirectory() returns true but isRootDirectory() returns false). Upon exit, the Path will refer to the directory above it.

Exceptions:
nothing 
Returns:
false if the directory name could not be removed.

Definition at line 345 of file Unix/Path.cpp.

References isFile().

bool llvm::sys::Path::elideFile  ) 
 

Removes the last file component of the path.

One file component is removed from the Path name. The Path must refer to a file (i.e. isFile() returns true). Upon exit, the Path will refer to the directory above it.

Exceptions:
nothing 
Returns:
false if the file name could not be removed

Definition at line 373 of file Unix/Path.cpp.

References isDirectory().

Referenced by llvm::sys::IsLibrary(), and llvm::IsLibrary().

bool llvm::sys::Path::elideSuffix  ) 
 

Remove the suffix from a path name.

The suffix of the filename is removed. 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.
Exceptions:
nothing 

Definition at line 398 of file Unix/Path.cpp.

References isDirectory().

Referenced by llvm::sys::IsLibrary(), and llvm::IsLibrary().

bool llvm::sys::Path::executable  )  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. Unlike isFile and isDirectory, this function actually checks for the existence and executability (by the current program) of the file.

Returns:
true if the pathname references an executable file.

Definition at line 228 of file Unix/Path.cpp.

Referenced by llvm::sys::Program::ExecuteAndWait(), and llvm::sys::Program::FindProgramByName().

bool llvm::sys::Path::exists  )  const
 

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. Unlike isFile and isDirectory, this function actually checks for the existence of the file or directory.

Returns:
true if the pathname references an existing file.

Definition at line 213 of file Unix/Path.cpp.

Referenced by llvm::Archive::addFileBefore(), destroyDirectory(), llvm::ArchiveMember::replaceWith(), and llvm::Archive::writeToDisk().

std::string llvm::sys::Path::get  )  const [inline]
 

Returns the path as a std::string.

This function returns the current contents of the path as a std::string. This allows the underlying path string to be manipulated by other software.

Returns:
std::string containing the path name.

Definition at line 325 of file Path.h.

Referenced by llvm::Archive::addFileBefore(), llvm::sys::Program::ExecuteAndWait(), llvm::Archive::fillHeader(), llvm::Archive::findModuleDefiningSymbol(), llvm::Archive::findModulesDefiningSymbols(), llvm::Archive::getAllModules(), llvm::GetBytecodeSymbols(), llvm::ArchiveMember::getMemberSize(), llvm::sys::MappedFile::map(), llvm::sys::RemoveFileOnSignal(), renameFile(), llvm::ArchiveMember::replaceWith(), llvm::Archive::writeMember(), and llvm::Archive::writeToDisk().

std::string llvm::sys::Path::getBasename  )  const
 

Get the base name of the path.

This function strips off the path and suffix of the file name and returns just the basename.

Returns:
std::string containing the basename of the path
Exceptions:
nothing 

Definition at line 148 of file Unix/Path.cpp.

Referenced by llvm::LinkModules().

bool llvm::Path::getDirectoryContents std::set< Path > &  paths  )  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:
false if this is not a directory, true otherwise
Exceptions:
std::string if the directory cannot be searched

Definition at line 271 of file Unix/Path.cpp.

References isDirectory(), path, and ThrowErrno().

std::string llvm::sys::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 52 of file AIX/Path.cpp.

Referenced by llvm::sys::IsLibrary(), and llvm::IsLibrary().

std::string llvm::sys::Path::getLast  )  const
 

Returns the last component of the path name.

This function returns the last component of the path name. If the isDirectory() function would return true then this returns the name of the last directory in the path. If the isFile() function would return true then this function returns the name of the file without any of the preceding directories.

Returns:
std::string containing the last component of the path name.

Definition at line 233 of file Unix/Path.cpp.

Referenced by llvm::sys::Program::ExecuteAndWait().

Path llvm::sys::Path::GetLibraryPath const std::string &  basename,
const std::vector< std::string > &  LibPaths
[static]
 

Locate a library in a platform specific manner.

Determine the platform-specific location of a library by first searching a list of library paths, then searching a list of "well known" paths for the platform. T

Returns:
a valid Path object if the library was found, an invalid one otherwise.
Exceptions:
nothing 

Definition at line 75 of file Unix/Path.cpp.

References clear(), E, I, llvm::sys::IsLibrary(), LLVM_LIBDIR, and setDirectory().

Path llvm::sys::Path::GetLLVMConfigDir  )  [static]
 

Construct a path to the LLVM installed configuration directory.

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.

Exceptions:
nothing 

Definition at line 119 of file Unix/Path.cpp.

References GetLLVMDefaultConfigDir(), LLVM_ETCDIR, and setDirectory().

Path llvm::sys::Path::GetLLVMDefaultConfigDir  )  [static]
 

Construct a path to the default LLVM configuration directory.

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.

Exceptions:
nothing 

Definition at line 114 of file Unix/Path.cpp.

References Path().

Referenced by GetLLVMConfigDir().

bool llvm::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.

Definition at line 173 of file Unix/Path.cpp.

References isFile().

Referenced by llvm::Archive::addFileBefore(), and llvm::ArchiveMember::replaceWith().

Path llvm::sys::Path::GetRootDirectory  )  [static]
 

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 C:\. Other operating systems may have different notions of what the root directory is.

Exceptions:
nothing 

Definition at line 44 of file Unix/Path.cpp.

References setDirectory().

Referenced by GetUserHomeDirectory().

void llvm::Path::getStatusInfo StatusInfo info  )  const
 

Get file status.

This function returns status information about the file. The type of path (file or directory) is updated to reflect the actual contents of the file system. If the file does not exist, false is returned. For other (hard I/O) errors, a std::string is throwing indicating the problem.

Exceptions:
std::string if an error occurs.

Definition at line 255 of file Unix/Path.cpp.

References llvm::sys::Path::StatusInfo::fileSize, llvm::sys::TimeValue::fromEpochTime(), llvm::sys::Path::StatusInfo::group, llvm::sys::Path::StatusInfo::isDir, llvm::sys::Path::StatusInfo::mode, llvm::sys::Path::StatusInfo::modTime, ThrowErrno(), and llvm::sys::Path::StatusInfo::user.

Referenced by llvm::Archive::addFileBefore(), and llvm::ArchiveMember::replaceWith().

Path llvm::sys::Path::GetSystemLibraryPath1  )  [static]
 

Construct a path to the first system library directory.

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.

Exceptions:
nothing 

Definition at line 104 of file Unix/Path.cpp.

References Path().

Path llvm::sys::Path::GetSystemLibraryPath2  )  [static]
 

Construct a path to the second system library directory.

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.

Exceptions:
nothing 

Definition at line 109 of file Unix/Path.cpp.

References Path().

Path llvm::sys::Path::GetTemporaryDirectory  )  [static]
 

Constrct 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.

Exceptions:
std::string indicating why the directory could not be created.

Definition at line 36 of file AIX/Path.cpp.

References isValid(), setDirectory(), and ThrowErrno().

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.

Exceptions:
nothing 

Definition at line 127 of file Unix/Path.cpp.

References GetRootDirectory(), and setDirectory().

bool llvm::sys::Path::hasMagicNumber const std::string &  magic  )  const
 

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.

Definition at line 159 of file Unix/Path.cpp.

Referenced by isArchive().

bool llvm::sys::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 205 of file Unix/Path.cpp.

References hasMagicNumber(), and readable().

bool llvm::sys::Path::isBytecodeFile  )  const
 

Determine if the path references a bytecode file.

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

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

Definition at line 192 of file Unix/Path.cpp.

References ThrowErrno().

bool llvm::sys::Path::isDirectory  )  const
 

Determines if the path name references a directory.

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

Definition at line 143 of file Unix/Path.cpp.

References isValid().

Referenced by appendFile(), appendSuffix(), createDirectory(), destroyDirectory(), elideFile(), elideSuffix(), getDirectoryContents(), and llvm::sys::RemoveDirectoryOnSignal().

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 has a zero length.

Returns:
true iff the path is empty.

Definition at line 228 of file Path.h.

Referenced by llvm::LinkModules().

bool llvm::sys::Path::isFile  )  const
 

Determines if the path name references a file.

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.

Definition at line 138 of file Unix/Path.cpp.

References isValid().

Referenced by appendDirectory(), createFile(), createTemporaryFile(), destroyFile(), elideDirectory(), getMagicNumber(), renameFile(), and setStatusInfo().

bool llvm::sys::Path::isRootDirectory  )  const
 

Determines if the path references the root directory.

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.

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.

Definition at line 27 of file AIX/Path.cpp.

Referenced by appendDirectory(), appendFile(), appendSuffix(), GetTemporaryDirectory(), isDirectory(), isFile(), setDirectory(), and setFile().

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.
Exceptions:
nothing 

Definition at line 196 of file Path.h.

References path.

bool llvm::sys::Path::operator< const Path that  )  const [inline]
 

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.
Exceptions:
nothing 

Definition at line 207 of file Path.h.

References path.

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

Assignment Operator.

Makes a copy of that to this.

Returns:
this
Exceptions:
nothing 

Definition at line 179 of file Path.h.

References path.

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

Equality Operator.

Compares this Path with that Path for equality.

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

Definition at line 188 of file Path.h.

References path.

bool llvm::sys::Path::readable  )  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. Unlike isFile and isDirectory, this function actually checks for the existence and readability (by the current program) of the file or directory.

Returns:
true if the pathname references a readable file.

Definition at line 218 of file Unix/Path.cpp.

Referenced by isArchive(), llvm::sys::IsLibrary(), and llvm::IsLibrary().

bool llvm::Path::renameFile const Path newName  ) 
 

Rename one file as another.

This method renames the file referenced by this as newName. Both files must exist before making this call.

Returns:
false if the Path does not refer to a file, true otherwise.
Exceptions:
std::string if there is an file system error.

Definition at line 522 of file Unix/Path.cpp.

References c_str(), get(), isFile(), and ThrowErrno().

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

bool llvm::sys::Path::setDirectory const std::string &  unverified_path  ) 
 

Set a full path from a std::string.

This method attempts to set the Path object to unverified_path and interpret the name as a directory name. The unverified_path is verified. If verification succeeds then unverified_path is accepted as a directory and true is returned. Otherwise, the Path object remains unchanged and false is returned.

Returns:
true if the path was set, false otherwise.
Parameters:
unverified_path The path to be set in Path object.
Exceptions:
nothing 

Definition at line 298 of file Unix/Path.cpp.

References isValid(), and path.

Referenced by llvm::sys::Program::FindProgramByName(), GetLibraryPath(), GetLLVMConfigDir(), GetRootDirectory(), GetTemporaryDirectory(), and GetUserHomeDirectory().

bool llvm::sys::Path::setFile const std::string &  unverified_path  ) 
 

Set a full path from a std::string.

This method attempts to set the Path object to unverified_path and interpret the name as a file name. The unverified_path is verified. If verification succeeds then unverified_path is accepted as a file name and true is returned. Otherwise, the Path object remains unchanged and false is returned.

Returns:
true if the path was set, false otherwise.
Parameters:
unverified_path The path to be set in Path object.
Exceptions:
nothing 

Definition at line 314 of file Unix/Path.cpp.

References isValid(), and path.

Referenced by llvm::sys::Program::FindProgramByName(), llvm::LinkModules(), and llvm::Archive::parseMemberHeader().

bool llvm::Path::setStatusInfo const StatusInfo si  )  const
 

Set file times and mode.

This method sets the access time, modification time, and permission mode of the file associated with this as given by si.

Returns:
false if the Path does not refer to a file, true otherwise.
Exceptions:
std::string if the file could not be modified

Definition at line 530 of file Unix/Path.cpp.

References isFile(), llvm::sys::Path::StatusInfo::mode, llvm::sys::Path::StatusInfo::modTime, ThrowErrno(), and llvm::sys::TimeValue::toPosixTime().

bool llvm::sys::Path::writable  )  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. Unlike isFile and isDirectory, this function actually checks for the existence and writability (by the current program) of the file or directory.

Returns:
true if the pathname references a writable file.

Definition at line 223 of file Unix/Path.cpp.


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