LLVM API Documentation

llvm::sys::Path Class Reference

An abstraction for operating system paths. More...

#include <Path.h>

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

List of all members.

Constructors

static Path GetRootDirectory ()
static Path GetTemporaryDirectory (std::string *ErrMsg=0)
 Constrct 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 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 Path GetCurrentDirectory ()
 Returns the current working directory.
static std::string GetDLLSuffix ()
 Return the dynamic link library suffix.
static Path GetMainExecutable (const char *argv0, void *MainAddr)
 Path ()
 Construct an empty (and invalid) path.
 Path (const Path &that)
 Path (const std::string &p)
 Construct a Path from a string.
 Path (const char *StrStart, unsigned StrLen)
 Construct a Path from a string.

Disk Mutators

static const char * MapInFilePages (int FD, uint64_t FileSize)
static void UnMapFilePages (const char *Base, uint64_t FileSize)
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.

Public Member Functions

Operators
Path & operator= (const Path &that)
 Assignment Operator.
Path & operator= (const std::string &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).
const std::string & toString () 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.
std::string getDirname () const
std::string getSuffix () const
 Get the suffix of the path.
const char * c_str () const
 Returns the path as a C string.
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
bool isRootDirectory () const
 Determines if the path references the root directory.
bool isAbsolute () const
 Determine if the path is absolute.
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 isBitcodeFile () const
 Determine if the path references a bitcode file.
bool isDynamicLibrary () const
 Determine if the path reference a dynamic library.
bool exists () const
 Determines if the path is a file or directory in the file system.
bool isDirectory () const
 Determins if the path is a directory 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 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 (const std::string &unverified_path)
 Set a full path from a std::string.
bool eraseComponent ()
 Removes the last directory component of the Path.
bool appendComponent (const std::string &component)
 Appends one path component to the Path.
bool appendSuffix (const std::string &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.

Protected Attributes

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


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

Definition at line 175 of file Path.h.

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

Definition at line 176 of file Path.h.

llvm::sys::Path::Path ( const std::string &  p  )  [explicit]

Construct a Path from a string.

This constructor will accept a 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:
p The 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:
StrStart A pointer to the first character of the path name
StrLen The length of the path name at StrStart


Member Function Documentation

static 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 or none at all. In that case, a consistent default root directory will be used.

static Path llvm::sys::Path::GetTemporaryDirectory ( std::string *  ErrMsg = 0  )  [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.

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

Referenced by llvm::WriteGraph().

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. This function *must* return the value of LLVM_LIB_SEARCH_PATH as the first item in Paths if that environment variable is set and it references a directory.

Referenced by FindLibrary().

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

Referenced by llvm::Linker::addSystemPaths().

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 172 of file Path.cpp.

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

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

Referenced by GetLLVMConfigDir().

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

Definition at line 45 of file Path.cpp.

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

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.

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.

std::string 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 188 of file Path.cpp.

References LTDL_SHLIB_EXT.

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.

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

References path.

Path& llvm::sys::Path::operator= ( const std::string &  that  ) 

Assignment Operator.

Makes a copy of that to this.

Parameters:
\p that A std::string 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 27 of file Path.cpp.

References path.

bool Path::operator!= ( const Path &  that  )  const

Inequality Operator.

Compares this Path with that Path for inequality.

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

Definition at line 31 of file Path.cpp.

References path.

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 35 of file Path.cpp.

References path.

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.

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

References path.

Referenced by llvm::FindExecutable(), llvm::Linker::FindLib(), llvm::Linker::LinkInLibrary(), llvm::Linker::LinkModules(), llvm::ViewGraph(), and llvm::WriteGraph().

const std::string& llvm::sys::Path::toString (  )  const [inline]

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. The last component is the file or directory name occuring after the last directory separator. If no directory separator is present, the entire path name is returned (i.e. same as toString).

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

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 or directory name and returns just the basename. For example /a/foo.bar would cause this function to return "foo".

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

Referenced by llvm::Linker::LinkModules().

std::string llvm::sys::Path::getDirname (  )  const

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

std::string llvm::sys::Path::getSuffix (  )  const

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:
std::string containing the suffix of the path

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

References path.

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

size_t llvm::sys::Path::size (  )  const [inline]

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

Definition at line 290 of file Path.h.

References path.

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

empty - Returns true if the path is empty.

Definition at line 293 of file Path.h.

References path.

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::isAbsolute (  )  const

Determine if the path is absolute.

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

bool 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 203 of file Path.cpp.

References getMagicNumber().

Referenced by isArchive().

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.

Referenced by llvm::Archive::addFileBefore(), hasMagicNumber(), isBitcodeFile(), isDynamicLibrary(), llvm::Linker::LinkInFile(), llvm::Linker::LinkInLibrary(), and llvm::ArchiveMember::replaceWith().

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 147 of file Path.cpp.

References canRead(), and hasMagicNumber().

Referenced by llvm::Linker::FindLib(), FindLibrary(), IsLibrary(), and llvm::Linker::LinkInArchive().

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 193 of file Path.cpp.

References llvm::sys::Bitcode_FileType, getMagicNumber(), and llvm::sys::IdentifyFileType().

Referenced by IsLibrary().

bool Path::isDynamicLibrary (  )  const

Determine if the path reference 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:
strue if the file starts with the magid number for a native shared library.

Definition at line 154 of file Path.cpp.

References canRead(), llvm::sys::COFF_FileType, llvm::sys::ELF_SharedObject_FileType, getMagicNumber(), llvm::sys::IdentifyFileType(), llvm::sys::Mach_O_DynamicallyLinkedSharedLib_FileType, llvm::sys::Mach_O_DynamicallyLinkedSharedLibStub_FileType, and llvm::sys::Mach_O_FixedVirtualMemorySharedLib_FileType.

Referenced by llvm::Linker::FindLib(), FindLibrary(), and IsLibrary().

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.

Returns:
true if the pathname references an existing file or directory.

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

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

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

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

Returns:
true if the pathname references an existing directory.

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 llvm::Linker::FindLib(), getPathList(), llvm::SourceFileInfo::getSourceText(), isArchive(), isDynamicLibrary(), and llvm::Linker::LinkInFile().

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.

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.

Referenced by llvm::FindExecutable().

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:
paths  The resulting list of file & directory names
ErrMsg  Optional place to return an error message.

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

References path.

Referenced by IsLibrary().

bool llvm::sys::Path::set ( const std::string &  unverified_path  ) 

Set a full path from a std::string.

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_path The path to be set in Path object.

Referenced by llvm::Linker::addPaths(), GetLLVMConfigDir(), getPathList(), llvm::SourceFileInfo::getSourceText(), llvm::Linker::LinkModules(), and llvm::Archive::parseMemberHeader().

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::FindExecutable().

bool llvm::sys::Path::appendComponent ( const std::string &  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 llvm::FindExecutable(), FindLibrary(), llvm::SourceFileInfo::getSourceText(), IsLibrary(), and llvm::WriteGraph().

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.

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

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(), and IsLibrary().

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::string if an unrecoverable error occurs.

Referenced by llvm::WriteGraph().

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::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().

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::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::string if an error occurs.
Returns:
true on error.

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_parents  Determines whether non-existent directory components other than the last one (the "parents") are created or not.
ErrMsg  Optional 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:
ErrMsg  Optional 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_current  When set to true, this parameter indicates that if the current file name does not exist then it will be used without modification.
ErrMsg  Optional place to put error messages

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

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::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_contents Indicates whether the contents of a destroyed
Err An 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 llvm::DisplayGraph(), llvm::Archive::writeToDisk(), and llvm::FileRemover::~FileRemover().

static const char* llvm::sys::Path::MapInFilePages ( int  FD,
uint64_t  FileSize 
) [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.

Referenced by llvm::MemoryBuffer::getFile().

static void llvm::sys::Path::UnMapFilePages ( const char *  Base,
uint64_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 580 of file Path.h.

Referenced by c_str(), clear(), empty(), isEmpty(), operator!=(), operator<(), operator=(), operator==(), size(), and toString().


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