LLVM API Documentation
Namespaces | |
namespace | detail |
Classes | |
struct | space_info |
space_info - Self explanatory. More... | |
class | UniqueID |
class | file_status |
struct | file_magic |
class | mapped_file_region |
class | directory_entry |
class | directory_iterator |
class | recursive_directory_iterator |
Enumerations | |
enum | file_type { status_error, file_not_found, regular_file, directory_file, symlink_file, block_file, character_file, fifo_file, socket_file, type_unknown } |
An enumeration for the file system's view of the type. More... | |
enum | perms { no_perms = 0, owner_read = 0400, owner_write = 0200, owner_exe = 0100, owner_all = owner_read | owner_write | owner_exe, group_read = 040, group_write = 020, group_exe = 010, group_all = group_read | group_write | group_exe, others_read = 04, others_write = 02, others_exe = 01, others_all = others_read | others_write | others_exe, all_read = owner_read | group_read | others_read, all_write = owner_write | group_write | others_write, all_exe = owner_exe | group_exe | others_exe, all_all = owner_all | group_all | others_all, set_uid_on_exe = 04000, set_gid_on_exe = 02000, sticky_bit = 01000, perms_not_known = 0xFFFF } |
enum | AccessMode { Exist, Write, Execute } |
enum | OpenFlags { F_None = 0, F_Excl = 1, F_Append = 2, F_Text = 4, F_RW = 8 } |
Functions | |
perms | operator| (perms l, perms r) |
perms | operator& (perms l, perms r) |
perms & | operator|= (perms &l, perms r) |
perms & | operator&= (perms &l, perms r) |
perms | operator~ (perms x) |
std::error_code | make_absolute (SmallVectorImpl< char > &path) |
Make path an absolute path. | |
std::error_code | create_directories (const Twine &path, bool IgnoreExisting=true) |
Create all the non-existent directories in path. | |
std::error_code | create_directory (const Twine &path, bool IgnoreExisting=true) |
Create the directory in path. | |
std::error_code | create_link (const Twine &to, const Twine &from) |
Create a link from from to to. | |
std::error_code | current_path (SmallVectorImpl< char > &result) |
Get the current path. | |
std::error_code | remove (const Twine &path, bool IgnoreNonExisting=true) |
Remove path. Equivalent to POSIX remove(). | |
std::error_code | rename (const Twine &from, const Twine &to) |
Rename from to to. Files are renamed as if by POSIX rename(). | |
std::error_code | copy_file (const Twine &From, const Twine &To) |
Copy the contents of From to To. | |
std::error_code | resize_file (const Twine &path, uint64_t size) |
Resize path to size. File is resized as if by POSIX truncate(). | |
bool | exists (file_status status) |
Does file exist? | |
std::error_code | access (const Twine &Path, AccessMode Mode) |
Can the file be accessed? | |
bool | exists (const Twine &Path) |
Does file exist? | |
bool | can_execute (const Twine &Path) |
Can we execute this file? | |
bool | can_write (const Twine &Path) |
Can we write this file? | |
bool | equivalent (file_status A, file_status B) |
Do file_status's represent the same thing? | |
std::error_code | equivalent (const Twine &A, const Twine &B, bool &result) |
Do paths represent the same thing? | |
bool | equivalent (const Twine &A, const Twine &B) |
Simpler version of equivalent for clients that don't need to differentiate between an error and false. | |
bool | is_directory (file_status status) |
Does status represent a directory? | |
std::error_code | is_directory (const Twine &path, bool &result) |
Is path a directory? | |
bool | is_directory (const Twine &Path) |
Simpler version of is_directory for clients that don't need to differentiate between an error and false. | |
bool | is_regular_file (file_status status) |
Does status represent a regular file? | |
std::error_code | is_regular_file (const Twine &path, bool &result) |
Is path a regular file? | |
bool | is_regular_file (const Twine &Path) |
Simpler version of is_regular_file for clients that don't need to differentiate between an error and false. | |
bool | is_other (file_status status) |
Does this status represent something that exists but is not a directory, regular file, or symlink? | |
std::error_code | is_other (const Twine &path, bool &result) |
Is path something that exists but is not a directory, regular file, or symlink? | |
std::error_code | status (const Twine &path, file_status &result) |
Get file status as if by POSIX stat(). | |
std::error_code | status (int FD, file_status &Result) |
A version for when a file descriptor is already available. | |
std::error_code | file_size (const Twine &Path, uint64_t &Result) |
Get file size. | |
std::error_code | setLastModificationAndAccessTime (int FD, TimeValue Time) |
Set the file modification and access time. | |
bool | status_known (file_status s) |
Is status available? | |
std::error_code | status_known (const Twine &path, bool &result) |
Is status available? | |
std::error_code | createUniqueFile (const Twine &Model, int &ResultFD, SmallVectorImpl< char > &ResultPath, unsigned Mode=all_read|all_write) |
Create a uniquely named file. | |
std::error_code | createUniqueFile (const Twine &Model, SmallVectorImpl< char > &ResultPath) |
Simpler version for clients that don't want an open file. | |
std::error_code | createTemporaryFile (const Twine &Prefix, StringRef Suffix, int &ResultFD, SmallVectorImpl< char > &ResultPath) |
Create a file in the system temporary directory. | |
std::error_code | createTemporaryFile (const Twine &Prefix, StringRef Suffix, SmallVectorImpl< char > &ResultPath) |
Simpler version for clients that don't want an open file. | |
std::error_code | createUniqueDirectory (const Twine &Prefix, SmallVectorImpl< char > &ResultPath) |
OpenFlags | operator| (OpenFlags A, OpenFlags B) |
OpenFlags & | operator|= (OpenFlags &A, OpenFlags B) |
std::error_code | openFileForWrite (const Twine &Name, int &ResultFD, OpenFlags Flags, unsigned Mode=0666) |
std::error_code | openFileForRead (const Twine &Name, int &ResultFD) |
file_magic | identify_magic (StringRef magic) |
Identify the type of a binary file based on how magical it is. | |
std::error_code | identify_magic (const Twine &path, file_magic &result) |
Get and identify path's type based on its content. | |
std::error_code | getUniqueID (const Twine Path, UniqueID &Result) |
std::string | getMainExecutable (const char *argv0, void *MainExecAddr) |
static std::error_code | createTemporaryFile (const Twine &Model, int &ResultFD, llvm::SmallVectorImpl< char > &ResultPath, FSEntity Type) |
static std::error_code | createTemporaryFile (const Twine &Prefix, StringRef Suffix, int &ResultFD, llvm::SmallVectorImpl< char > &ResultPath, FSEntity Type) |
Definition at line 351 of file FileSystem.h.
An enumeration for the file system's view of the type.
status_error | |
file_not_found | |
regular_file | |
directory_file | |
symlink_file | |
block_file | |
character_file | |
fifo_file | |
socket_file | |
type_unknown |
Definition at line 53 of file FileSystem.h.
F_None | |
F_Excl |
F_Excl - When opening a file, this flag makes raw_fd_ostream report an error if the file already exists. |
F_Append |
F_Append - When opening a file, if it already exists append to the existing file instead of returning an error. This may not be specified with F_Excl. |
F_Text |
The file should be opened in text mode on platforms that make this distinction. |
F_RW |
Open the file for read and write. |
Definition at line 572 of file FileSystem.h.
enum llvm::sys::fs::perms |
Definition at line 73 of file FileSystem.h.
std::error_code llvm::sys::fs::access | ( | const Twine & | Path, |
AccessMode | Mode | ||
) |
Can the file be accessed?
Path | Input path. |
Referenced by can_execute(), can_write(), createUniqueEntity(), exists(), and llvm::LockFileManager::waitForUnlock().
bool llvm::sys::fs::can_execute | ( | const Twine & | Path | ) | [inline] |
Can we execute this file?
Path | Input path. |
Definition at line 372 of file FileSystem.h.
bool llvm::sys::fs::can_write | ( | const Twine & | Path | ) | [inline] |
Can we write this file?
Path | Input path. |
Definition at line 380 of file FileSystem.h.
std::error_code llvm::sys::fs::copy_file | ( | const Twine & | From, |
const Twine & | To | ||
) |
Copy the contents of From to To.
From | The path to copy from. |
To | The path to copy to. This is created. |
Definition at line 819 of file Path.cpp.
References F_None, openFileForRead(), openFileForWrite(), llvm::LibFunc::read, and llvm::LibFunc::write.
std::error_code llvm::sys::fs::create_directories | ( | const Twine & | path, |
bool | IgnoreExisting = true |
||
) |
Create all the non-existent directories in path.
path | Directories to create. |
Definition at line 796 of file Path.cpp.
References create_directory(), llvm::StringRef::empty(), llvm::no_such_file_or_directory, P, llvm::sys::path::parent_path(), and llvm::Twine::toStringRef().
std::error_code llvm::sys::fs::create_directory | ( | const Twine & | path, |
bool | IgnoreExisting = true |
||
) |
Create the directory in path.
path | Directory to create. |
Referenced by create_directories(), and createUniqueEntity().
std::error_code llvm::sys::fs::create_link | ( | const Twine & | to, |
const Twine & | from | ||
) |
Create a link from from to to.
The link may be a soft or a hard link, depending on the platform. The caller may not assume which one. Currently on windows it creates a hard link since soft links require extra privileges. On unix, it creates a soft link since hard links don't work on SMB file systems.
to | The path to hard link to. |
from | The path to hard link from. This is created. |
Referenced by llvm::LockFileManager::LockFileManager().
std::error_code llvm::sys::fs::createTemporaryFile | ( | const Twine & | Prefix, |
StringRef | Suffix, | ||
int & | ResultFD, | ||
SmallVectorImpl< char > & | ResultPath | ||
) |
Create a file in the system temporary directory.
The filename is of the form prefix-random_chars.suffix. Since the directory is not know to the caller, Prefix and Suffix cannot have path separators. The files are created with mode 0600.
This should be used for things like a temporary .s that is removed after running the assembler.
Definition at line 721 of file Path.cpp.
References FS_File.
Referenced by llvm::LTOCodeGenerator::compile_to_file(), llvm::createGraphFilename(), and createTemporaryFile().
std::error_code llvm::sys::fs::createTemporaryFile | ( | const Twine & | Prefix, |
StringRef | Suffix, | ||
SmallVectorImpl< char > & | ResultPath | ||
) |
Simpler version for clients that don't want an open file.
Definition at line 727 of file Path.cpp.
References createTemporaryFile(), llvm::NVPTXISD::Dummy, and FS_Name.
static std::error_code llvm::sys::fs::createTemporaryFile | ( | const Twine & | Model, |
int & | ResultFD, | ||
llvm::SmallVectorImpl< char > & | ResultPath, | ||
FSEntity | Type | ||
) | [static] |
Definition at line 702 of file Path.cpp.
References llvm::StringRef::begin(), createUniqueEntity(), llvm::StringRef::find_first_of(), llvm::StringRef::npos, owner_read, owner_write, P, llvm::Twine::toNullTerminatedStringRef(), and Type.
static std::error_code llvm::sys::fs::createTemporaryFile | ( | const Twine & | Prefix, |
StringRef | Suffix, | ||
int & | ResultFD, | ||
llvm::SmallVectorImpl< char > & | ResultPath, | ||
FSEntity | Type | ||
) | [static] |
Definition at line 714 of file Path.cpp.
References createTemporaryFile(), and llvm::StringRef::empty().
std::error_code llvm::sys::fs::createUniqueDirectory | ( | const Twine & | Prefix, |
SmallVectorImpl< char > & | ResultPath | ||
) |
Definition at line 736 of file Path.cpp.
References createUniqueEntity(), llvm::NVPTXISD::Dummy, and FS_Dir.
std::error_code llvm::sys::fs::createUniqueFile | ( | const Twine & | Model, |
int & | ResultFD, | ||
SmallVectorImpl< char > & | ResultPath, | ||
unsigned | Mode = all_read | all_write |
||
) |
Create a uniquely named file.
Generates a unique path suitable for a temporary file and then opens it as a file. The name is based on model with '' replaced by a random char in [0-9a-f]. If model is not an absolute path, a suitable temporary directory will be prepended.
Example: clang-%%-%%-%%-%%-%%.s => clang-a0-b1-c2-d3-e4.s
This is an atomic operation. Either the file is created and opened, or the file system is left untouched.
The intendend use is for files that are to be kept, possibly after renaming them. For example, when running 'clang -c foo.o', the file can be first created as foo-abc123.o and then renamed.
Model | Name to base unique path off of. |
ResultFD | Set to the opened file's file descriptor. |
ResultPath | Set to the opened file's absolute path. |
Definition at line 689 of file Path.cpp.
References createUniqueEntity(), and FS_File.
Referenced by llvm::FileOutputBuffer::create(), and llvm::LockFileManager::LockFileManager().
std::error_code llvm::sys::fs::createUniqueFile | ( | const Twine & | Model, |
SmallVectorImpl< char > & | ResultPath | ||
) |
Simpler version for clients that don't want an open file.
Definition at line 695 of file Path.cpp.
References createUniqueEntity(), llvm::NVPTXISD::Dummy, and FS_Name.
std::error_code llvm::sys::fs::current_path | ( | SmallVectorImpl< char > & | result | ) |
Get the current path.
result | Holds the current path on return. |
Referenced by make_absolute(), and llvm::MCContext::MCContext().
bool llvm::sys::fs::equivalent | ( | file_status | A, |
file_status | B | ||
) |
Do file_status's represent the same thing?
A | Input file_status. |
B | Input file_status. |
assert(status_known(A) || status_known(B));
std::error_code llvm::sys::fs::equivalent | ( | const Twine & | A, |
const Twine & | B, | ||
bool & | result | ||
) |
Do paths represent the same thing?
assert(status_known(A) || status_known(B));
A | Input path A. |
B | Input path B. |
result | Set to true if stat(A) and stat(B) have the same device and inode (or equivalent). |
bool llvm::sys::fs::equivalent | ( | const Twine & | A, |
const Twine & | B | ||
) | [inline] |
Simpler version of equivalent for clients that don't need to differentiate between an error and false.
Definition at line 409 of file FileSystem.h.
bool llvm::sys::fs::exists | ( | file_status | status | ) |
Does file exist?
status | A file_status previously returned from stat. |
Definition at line 853 of file Path.cpp.
References file_not_found, status_known(), and llvm::sys::fs::file_status::type().
Referenced by llvm::sys::Process::FindInEnvPath(), is_other(), llvm::LockFileManager::LockFileManager(), and llvm::LockFileManager::waitForUnlock().
bool llvm::sys::fs::exists | ( | const Twine & | Path | ) | [inline] |
Does file exist?
Path | Input path. |
Definition at line 364 of file FileSystem.h.
std::error_code llvm::sys::fs::file_size | ( | const Twine & | Path, |
uint64_t & | Result | ||
) | [inline] |
Get file size.
Path | Input path. |
Result | Set to the size of the file in Path. |
Definition at line 494 of file FileSystem.h.
References llvm::sys::fs::file_status::getSize(), and status().
std::string llvm::sys::fs::getMainExecutable | ( | const char * | argv0, |
void * | MainExecAddr | ||
) |
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.
std::error_code llvm::sys::fs::getUniqueID | ( | const Twine | Path, |
UniqueID & | Result | ||
) |
Definition at line 680 of file Path.cpp.
References llvm::sys::fs::file_status::getUniqueID(), and status().
Identify the type of a binary file based on how magical it is.
Identify the magic in magic.
Definition at line 900 of file Path.cpp.
References llvm::COFF::BigObjMagic, llvm::StringRef::data(), llvm::LibFunc::memcmp, llvm::COFF::BigObjHeader::MinBigObjectVersion, llvm::StringRef::size(), and llvm::IndexedInstrProf::Version.
Referenced by llvm::object::createBinary(), llvm::object::ObjectFile::createObjectFile(), llvm::object::SymbolicFile::createSymbolicFile(), identify_magic(), llvm::LTOModule::isBitcodeFile(), and llvm::RuntimeDyld::loadObject().
std::error_code llvm::sys::fs::identify_magic | ( | const Twine & | path, |
file_magic & | result | ||
) |
Get and identify path's type based on its content.
path | Input path. |
result | Set to the type of file, or file_magic::unknown. |
Definition at line 1044 of file Path.cpp.
References identify_magic(), openFileForRead(), and llvm::LibFunc::read.
bool llvm::sys::fs::is_directory | ( | file_status | status | ) |
Does status represent a directory?
status | A file_status previously returned from status. |
Definition at line 861 of file Path.cpp.
References directory_file, and llvm::sys::fs::file_status::type().
Referenced by is_directory(), and is_other().
std::error_code llvm::sys::fs::is_directory | ( | const Twine & | path, |
bool & | result | ||
) |
Is path a directory?
path | Input path. |
result | Set to true if path is a directory, false if it is not. Undefined otherwise. |
Definition at line 865 of file Path.cpp.
References is_directory(), and status().
bool llvm::sys::fs::is_directory | ( | const Twine & | Path | ) | [inline] |
Simpler version of is_directory for clients that don't need to differentiate between an error and false.
Definition at line 431 of file FileSystem.h.
bool llvm::sys::fs::is_other | ( | file_status | status | ) |
Does this status represent something that exists but is not a directory, regular file, or symlink?
status | A file_status previously returned from status. |
Definition at line 885 of file Path.cpp.
References exists(), is_directory(), and is_regular_file().
std::error_code llvm::sys::fs::is_other | ( | const Twine & | path, |
bool & | result | ||
) |
Is path something that exists but is not a directory, regular file, or symlink?
path | Input path. |
result | Set to true if path exists, but is not a directory, regular file, or a symlink, false if it does not. Undefined otherwise. |
bool llvm::sys::fs::is_regular_file | ( | file_status | status | ) |
Does status represent a regular file?
status | A file_status previously returned from status. |
Definition at line 873 of file Path.cpp.
References regular_file, and llvm::sys::fs::file_status::type().
Referenced by is_other(), and is_regular_file().
std::error_code llvm::sys::fs::is_regular_file | ( | const Twine & | path, |
bool & | result | ||
) |
Is path a regular file?
path | Input path. |
result | Set to true if path is a regular file, false if it is not. Undefined otherwise. |
Definition at line 877 of file Path.cpp.
References is_regular_file(), and status().
bool llvm::sys::fs::is_regular_file | ( | const Twine & | Path | ) | [inline] |
Simpler version of is_regular_file for clients that don't need to differentiate between an error and false.
Definition at line 453 of file FileSystem.h.
std::error_code llvm::sys::fs::make_absolute | ( | SmallVectorImpl< char > & | path | ) |
Make path an absolute path.
Makes path absolute using the current directory if it is not already. An empty path will result in the current directory.
/absolute/path => /absolute/path relative/../path => <current-directory>/relative/../path
path | A path that is modified to be an absolute path. |
Definition at line 743 of file Path.cpp.
References llvm::sys::path::append(), llvm::StringRef::begin(), current_path(), llvm::SmallVectorTemplateCommon< T, typename >::data(), llvm::StringRef::end(), llvm::sys::path::has_root_directory(), llvm::sys::path::has_root_name(), llvm_unreachable, llvm::sys::path::relative_path(), llvm::sys::path::root_directory(), llvm::sys::path::root_name(), llvm::SmallVectorTemplateCommon< T, typename >::size(), and llvm::SmallVectorImpl< T >::swap().
Referenced by llvm::LockFileManager::LockFileManager().
std::error_code llvm::sys::fs::openFileForRead | ( | const Twine & | Name, |
int & | ResultFD | ||
) |
Referenced by copy_file(), getFileAux(), and identify_magic().
std::error_code llvm::sys::fs::openFileForWrite | ( | const Twine & | Name, |
int & | ResultFD, | ||
OpenFlags | Flags, | ||
unsigned | Mode = 0666 |
||
) |
Referenced by copy_file(), createUniqueEntity(), and llvm::raw_fd_ostream::raw_fd_ostream().
perms llvm::sys::fs::operator& | ( | perms | l, |
perms | r | ||
) | [inline] |
Definition at line 102 of file FileSystem.h.
perms& llvm::sys::fs::operator&= | ( | perms & | l, |
perms | r | ||
) | [inline] |
Definition at line 110 of file FileSystem.h.
perms llvm::sys::fs::operator| | ( | perms | l, |
perms | r | ||
) | [inline] |
Definition at line 98 of file FileSystem.h.
OpenFlags llvm::sys::fs::operator| | ( | OpenFlags | A, |
OpenFlags | B | ||
) | [inline] |
Definition at line 592 of file FileSystem.h.
perms& llvm::sys::fs::operator|= | ( | perms & | l, |
perms | r | ||
) | [inline] |
Definition at line 106 of file FileSystem.h.
OpenFlags& llvm::sys::fs::operator|= | ( | OpenFlags & | A, |
OpenFlags | B | ||
) | [inline] |
Definition at line 596 of file FileSystem.h.
perms llvm::sys::fs::operator~ | ( | perms | x | ) | [inline] |
Definition at line 114 of file FileSystem.h.
std::error_code llvm::sys::fs::remove | ( | const Twine & | path, |
bool | IgnoreNonExisting = true |
||
) |
Remove path. Equivalent to POSIX remove().
path | Input path. |
Referenced by ExecGraphViewer(), and llvm::LockFileManager::LockFileManager().
std::error_code llvm::sys::fs::rename | ( | const Twine & | from, |
const Twine & | to | ||
) |
Rename from to to. Files are renamed as if by POSIX rename().
from | The path to rename from. |
to | The path to rename to. This is created. |
std::error_code llvm::sys::fs::resize_file | ( | const Twine & | path, |
uint64_t | size | ||
) |
Resize path to size. File is resized as if by POSIX truncate().
path | Input path. |
size | Size to resize to. |
Referenced by llvm::FileOutputBuffer::commit().
std::error_code llvm::sys::fs::setLastModificationAndAccessTime | ( | int | FD, |
TimeValue | Time | ||
) |
Set the file modification and access time.
std::error_code llvm::sys::fs::status | ( | const Twine & | path, |
file_status & | result | ||
) |
Get file status as if by POSIX stat().
path | Input path. |
result | Set to the file status. |
Referenced by ConstantFoldConvertToInt(), ConstantFoldScalarCall(), llvm::APFloat::convertFromSignExtendedInteger(), llvm::APFloat::convertToInteger(), llvm::FileOutputBuffer::create(), DecodeJMPL(), DecodeMem(), DecodeReturn(), DecodeSWAP(), file_size(), getOpenFileImpl(), getUniqueID(), is_directory(), is_regular_file(), shouldUseMmap(), and llvm::sys::fs::directory_entry::status().
std::error_code llvm::sys::fs::status | ( | int | FD, |
file_status & | Result | ||
) |
A version for when a file descriptor is already available.
bool llvm::sys::fs::status_known | ( | file_status | s | ) |
Is status available?
s | Input file status. |
Definition at line 857 of file Path.cpp.
References status_error, and llvm::sys::fs::file_status::type().
Referenced by exists().
std::error_code llvm::sys::fs::status_known | ( | const Twine & | path, |
bool & | result | ||
) |
Is status available?
path | Input path. |
result | Set to true if status() != status_error. |