LLVM API Documentation
Namespaces | |
| namespace | detail |
Classes | |
| struct | file_type |
| struct | copy_option |
| struct | space_info |
| space_info - Self explanatory. More... | |
| class | file_status |
| struct | file_magic |
| class | mapped_file_region |
| class | directory_entry |
| class | directory_iterator |
| class | recursive_directory_iterator |
Enumerations | |
| 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_all = owner_all | group_all | others_all, set_uid_on_exe = 04000, set_gid_on_exe = 02000, sticky_bit = 01000, perms_mask = all_all | set_uid_on_exe | set_gid_on_exe | sticky_bit, perms_not_known = 0xFFFF, add_perms = 0x1000, remove_perms = 0x2000, symlink_perms = 0x4000 } |
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) |
Physical Operators | |
| error_code | make_absolute (SmallVectorImpl< char > &path) |
| Make path an absolute path. | |
| error_code | copy_file (const Twine &from, const Twine &to, copy_option copt=copy_option::fail_if_exists) |
| Copy the file at from to the path to. | |
| error_code | create_directories (const Twine &path, bool &existed) |
| Create all the non-existent directories in path. | |
| error_code | create_directory (const Twine &path, bool &existed) |
| Create the directory in path. | |
| error_code | create_hard_link (const Twine &to, const Twine &from) |
| Create a hard link from from to to. | |
| error_code | create_symlink (const Twine &to, const Twine &from) |
| Create a symbolic link from from to to. | |
| error_code | current_path (SmallVectorImpl< char > &result) |
| Get the current path. | |
| error_code | remove (const Twine &path, bool &existed) |
| Remove path. Equivalent to POSIX remove(). | |
| error_code | remove_all (const Twine &path, uint32_t &num_removed) |
| Recursively remove all files below path, then path. Files are removed as if by POSIX remove(). | |
| error_code | rename (const Twine &from, const Twine &to) |
| Rename from to to. Files are renamed as if by POSIX rename(). | |
| error_code | resize_file (const Twine &path, uint64_t size) |
| Resize path to size. File is resized as if by POSIX truncate(). | |
Physical Observers | |
| bool | exists (file_status status) |
| Does file exist? | |
| error_code | exists (const Twine &path, bool &result) |
| Does file exist? | |
| bool | exists (const Twine &path) |
| Simpler version of exists for clients that don't need to differentiate between an error and false. | |
| bool | equivalent (file_status A, file_status B) |
| Do file_status's represent the same thing? | |
| 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. | |
| error_code | file_size (const Twine &path, uint64_t &result) |
| Get file size. | |
| bool | is_directory (file_status status) |
| Does status represent a directory? | |
| error_code | is_directory (const Twine &path, bool &result) |
| Is path a directory? | |
| bool | is_regular_file (file_status status) |
| Does status represent a regular file? | |
| error_code | is_regular_file (const Twine &path, bool &result) |
| Is path a regular file? | |
| bool | is_other (file_status status) |
| Does this status represent something that exists but is not a directory, regular file, or symlink? | |
| error_code | is_other (const Twine &path, bool &result) |
| Is path something that exists but is not a directory, regular file, or symlink? | |
| bool | is_symlink (file_status status) |
| Does status represent a symlink? | |
| error_code | is_symlink (const Twine &path, bool &result) |
| Is path a symlink? | |
| error_code | status (const Twine &path, file_status &result) |
| Get file status as if by POSIX stat(). | |
| error_code | permissions (const Twine &path, perms prms) |
| Modifies permission bits on a file. | |
| bool | status_known (file_status s) |
| Is status available? | |
| error_code | status_known (const Twine &path, bool &result) |
| Is status available? | |
| error_code | unique_file (const Twine &model, int &result_fd, SmallVectorImpl< char > &result_path, bool makeAbsolute=true, unsigned mode=0600) |
| Generate a unique path and open it as a file. | |
| error_code | canonicalize (const Twine &path, SmallVectorImpl< char > &result) |
| Canonicalize path. | |
| error_code | has_magic (const Twine &path, const Twine &magic, bool &result) |
| Are path's first bytes magic? | |
| error_code | get_magic (const Twine &path, uint32_t len, SmallVectorImpl< char > &result) |
| Get path's first len bytes. | |
| file_magic | identify_magic (StringRef magic) |
| Identify the type of a binary file based on how magical it is. | |
| error_code | identify_magic (const Twine &path, file_magic &result) |
| Get and identify path's type based on its content. | |
| error_code | GetSystemLibraryPaths (SmallVectorImpl< std::string > &result) |
| Get library paths the system linker uses. | |
| error_code | GetBitcodeLibraryPaths (SmallVectorImpl< std::string > &result) |
| Get bitcode library paths the system linker uses + LLVM_LIB_SEARCH_PATH + LLVM_LIBDIR. | |
| error_code | FindLibrary (const Twine &short_name, SmallVectorImpl< char > &result) |
| Find a library. | |
| error_code | GetMainExecutable (const char *argv0, void *MainAddr, SmallVectorImpl< char > &result) |
| Get absolute path of main executable. | |
| error_code | map_file_pages (const Twine &path, off_t file_offset, size_t size, bool map_writable, void *&result) |
| Memory maps the contents of a file. | |
| error_code | unmap_file_pages (void *base, size_t size) |
| Memory unmaps the contents of a file. | |
| enum llvm::sys::fs::perms |
Definition at line 99 of file FileSystem.h.
| error_code llvm::sys::fs::canonicalize | ( | const Twine & | path, |
| SmallVectorImpl< char > & | result | ||
| ) |
Canonicalize path.
Sets result to the file system's idea of what path is. The result is always absolute and has the same capitalization as the file system.
| path | Input path. |
| result | Set to the canonicalized version of path. |
Referenced by llvm::ImmutableSetRef< ValT, ValInfo >::asImmutableSet().
| error_code llvm::sys::fs::copy_file | ( | const Twine & | from, |
| const Twine & | to, | ||
| copy_option | copt = copy_option::fail_if_exists |
||
| ) |
Copy the file at from to the path to.
| from | The path to copy the file from. |
| to | The path to copy the file to. |
| copt | Behavior if to already exists. |
| error_code llvm::sys::fs::create_directories | ( | const Twine & | path, |
| bool & | existed | ||
| ) |
Create all the non-existent directories in path.
| path | Directories to create. |
| existed | Set to true if path already existed, false otherwise. |
Definition at line 677 of file PathV2.cpp.
References create_directory(), llvm::StringRef::empty(), exists(), llvm::sys::path::parent_path(), and llvm::Twine::toStringRef().
| error_code llvm::sys::fs::create_directory | ( | const Twine & | path, |
| bool & | existed | ||
| ) |
Create the directory in path.
| path | Directory to create. |
| existed | Set to true if path already existed, false otherwise. |
Referenced by create_directories().
| error_code llvm::sys::fs::create_hard_link | ( | const Twine & | to, |
| const Twine & | from | ||
| ) |
Create a hard link from from to to.
| to | The path to hard link to. |
| from | The path to hard link from. This is created. |
Referenced by llvm::LockFileManager::LockFileManager().
| error_code llvm::sys::fs::create_symlink | ( | const Twine & | to, |
| const Twine & | from | ||
| ) |
Create a symbolic link from from to to.
| to | The path to symbolically link to. |
| from | The path to symbolically link from. This is created. |
| 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().
| 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));
Referenced by equivalent().
| 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 371 of file FileSystem.h.
References equivalent().
| bool llvm::sys::fs::exists | ( | file_status | status | ) |
Does file exist?
| status | A file_status previously returned from stat. |
Definition at line 693 of file PathV2.cpp.
References llvm::sys::fs::file_type::file_not_found, status_known(), and llvm::sys::fs::file_status::type().
Referenced by llvm::Archive::addFileBefore(), create_directories(), exists(), is_other(), llvm::ArchiveMember::replaceWith(), and llvm::LockFileManager::waitForUnlock().
| error_code llvm::sys::fs::exists | ( | const Twine & | path, |
| bool & | result | ||
| ) |
Does file exist?
| path | Input path. |
| result | Set to true if the file represented by status exists, false if it does not. Undefined otherwise. |
| bool llvm::sys::fs::exists | ( | const Twine & | path | ) | [inline] |
Simpler version of exists for clients that don't need to differentiate between an error and false.
Definition at line 341 of file FileSystem.h.
References exists().
| error_code llvm::sys::fs::file_size | ( | const Twine & | path, |
| uint64_t & | result | ||
| ) |
Get file size.
| path | Input path. |
| result | Set to the size of the file in path. |
| error_code llvm::sys::fs::FindLibrary | ( | const Twine & | short_name, |
| SmallVectorImpl< char > & | result | ||
| ) |
Find a library.
Find the path to a library using its short name. Use the system dependent library paths to locate the library.
c => /usr/lib/libc.so
| short_name | Library name one would give to the system linker. |
| result | Set to the absolute path short_name represents. |
| error_code llvm::sys::fs::get_magic | ( | const Twine & | path, |
| uint32_t | len, | ||
| SmallVectorImpl< char > & | result | ||
| ) |
Get path's first len bytes.
| path | Input path. |
| len | Number of magic bytes to get. |
| result | Set to the first len bytes in the file pointed to by path. Or the entire file if file_size(path) < len, in which case result.size() returns the size of the file. |
Referenced by has_magic(), identify_magic(), and llvm::ArchiveMember::replaceWith().
| error_code llvm::sys::fs::GetBitcodeLibraryPaths | ( | SmallVectorImpl< std::string > & | result | ) |
Get bitcode library paths the system linker uses + LLVM_LIB_SEARCH_PATH + LLVM_LIBDIR.
| result | Set to the list of bitcode library paths. |
| error_code llvm::sys::fs::GetMainExecutable | ( | const char * | argv0, |
| void * | MainAddr, | ||
| SmallVectorImpl< char > & | result | ||
| ) |
Get absolute path of main executable.
| argv0 | The program name as it was spelled on the command line. |
| MainAddr | Address of some symbol in the executable (not in a library). |
| result | Set to the absolute path of the current executable. |
| error_code llvm::sys::fs::GetSystemLibraryPaths | ( | SmallVectorImpl< std::string > & | result | ) |
Get library paths the system linker uses.
| result | Set to the list of system library paths. |
| error_code llvm::sys::fs::has_magic | ( | const Twine & | path, |
| const Twine & | magic, | ||
| bool & | result | ||
| ) |
Are path's first bytes magic?
| path | Input path. |
| magic | Byte sequence to compare path's first len(magic) bytes to. |
Definition at line 752 of file PathV2.cpp.
References get_magic(), Magic, llvm::StringRef::size(), llvm::error_code::success(), llvm::Twine::toStringRef(), and llvm::errc::value_too_large.
| file_magic llvm::sys::fs::identify_magic | ( | StringRef | magic | ) |
Identify the type of a binary file based on how magical it is.
Identify the magic in magic.
Definition at line 771 of file PathV2.cpp.
References llvm::sys::fs::file_magic::archive, llvm::sys::fs::file_magic::bitcode, llvm::sys::fs::file_magic::coff_object, llvm::StringRef::data(), llvm::sys::fs::file_magic::elf_core, llvm::sys::fs::file_magic::elf_executable, llvm::sys::fs::file_magic::elf_relocatable, llvm::sys::fs::file_magic::elf_shared_object, llvm::sys::fs::file_magic::macho_bundle, llvm::sys::fs::file_magic::macho_core, llvm::sys::fs::file_magic::macho_dsym_companion, llvm::sys::fs::file_magic::macho_dynamic_linker, llvm::sys::fs::file_magic::macho_dynamically_linked_shared_lib, llvm::sys::fs::file_magic::macho_executable, llvm::sys::fs::file_magic::macho_fixed_virtual_memory_shared_lib, llvm::sys::fs::file_magic::macho_object, llvm::sys::fs::file_magic::macho_preload_executabl, llvm::LibFunc::memcmp, llvm::sys::fs::file_magic::pecoff_executable, llvm::StringRef::size(), and llvm::sys::fs::file_magic::unknown.
Referenced by llvm::Archive::addFileBefore(), identify_magic(), llvm::sys::Path::isArchive(), llvm::sys::Path::isBitcodeFile(), llvm::sys::Path::isDynamicLibrary(), and llvm::sys::Path::isObjectFile().
| 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 LLVMFileType::Unknown_FileType. |
Definition at line 886 of file PathV2.cpp.
References llvm::SmallVectorTemplateCommon< char >::capacity(), get_magic(), identify_magic(), Magic, llvm::error_code::success(), and llvm::errc::value_too_large.
| 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 701 of file PathV2.cpp.
References llvm::sys::fs::file_type::directory_file, and llvm::sys::fs::file_status::type().
Referenced by llvm::MemoryBuffer::getFile(), llvm::sys::fs::recursive_directory_iterator::increment(), is_directory(), and is_other().
| 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 705 of file PathV2.cpp.
References is_directory(), status(), and llvm::error_code::success().
| 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 737 of file PathV2.cpp.
References exists(), is_directory(), is_regular_file(), and is_symlink().
| 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 713 of file PathV2.cpp.
References llvm::sys::fs::file_type::regular_file, and llvm::sys::fs::file_status::type().
Referenced by is_other(), and is_regular_file().
| 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 717 of file PathV2.cpp.
References is_regular_file(), status(), and llvm::error_code::success().
| bool llvm::sys::fs::is_symlink | ( | file_status | status | ) |
Does status represent a symlink?
| status | A file_status previously returned from stat. |
Definition at line 725 of file PathV2.cpp.
References llvm::sys::fs::file_type::symlink_file, and llvm::sys::fs::file_status::type().
Referenced by is_other(), and is_symlink().
| error_code llvm::sys::fs::is_symlink | ( | const Twine & | path, |
| bool & | result | ||
| ) |
Is path a symlink?
| path | Input path. |
| result | Set to true if path is a symlink, false if it is not. Undefined otherwise. |
Definition at line 729 of file PathV2.cpp.
References is_symlink(), status(), and llvm::error_code::success().
| 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 625 of file PathV2.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(), llvm::error_code::success(), and llvm::SmallVectorImpl< T >::swap().
| error_code llvm::sys::fs::map_file_pages | ( | const Twine & | path, |
| off_t | file_offset, | ||
| size_t | size, | ||
| bool | map_writable, | ||
| void *& | result | ||
| ) |
Memory maps the contents of a file.
| path | Path to file to map. |
| file_offset | Byte offset in file where mapping should begin. |
| size | Byte length of range of the file to map. |
| map_writable | If true, the file will be mapped in r/w such that changes to the mapped buffer will be flushed back to the file. If false, the file will be mapped read-only and the buffer will be read-only. |
| result | Set to the start address of the mapped buffer. |
| perms llvm::sys::fs::operator& | ( | perms | l, |
| perms | r | ||
| ) | [inline] |
Definition at line 129 of file FileSystem.h.
| perms& llvm::sys::fs::operator&= | ( | perms & | l, |
| perms | r | ||
| ) | [inline] |
Definition at line 137 of file FileSystem.h.
| perms llvm::sys::fs::operator| | ( | perms | l, |
| perms | r | ||
| ) | [inline] |
Definition at line 125 of file FileSystem.h.
| perms& llvm::sys::fs::operator|= | ( | perms & | l, |
| perms | r | ||
| ) | [inline] |
Definition at line 133 of file FileSystem.h.
| perms llvm::sys::fs::operator~ | ( | perms | x | ) | [inline] |
Definition at line 141 of file FileSystem.h.
| error_code llvm::sys::fs::permissions | ( | const Twine & | path, |
| perms | prms | ||
| ) |
Modifies permission bits on a file.
| path | Input path. |
Referenced by llvm::FileOutputBuffer::create().
| error_code llvm::sys::fs::remove | ( | const Twine & | path, |
| bool & | existed | ||
| ) |
Remove path. Equivalent to POSIX remove().
| path | Input path. |
| existed | Set to true if path existed, false if it did not. undefined otherwise. |
| error_code llvm::sys::fs::remove_all | ( | const Twine & | path, |
| uint32_t & | num_removed | ||
| ) |
Recursively remove all files below path, then path. Files are removed as if by POSIX remove().
| path | Input path. |
| num_removed | Number of files removed. |
Definition at line 924 of file PathV2.cpp.
References status(), llvm::Twine::toStringRef(), and llvm::sys::fs::file_status::type().
| 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. |
| 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().
| 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 llvm::ConstantFoldCall(), ConstantFoldConvertToInt(), llvm::APFloat::convertFromSignExtendedInteger(), llvm::APFloat::convertToInteger(), llvm::FileOutputBuffer::create(), is_directory(), is_regular_file(), is_symlink(), and remove_all().
| bool llvm::sys::fs::status_known | ( | file_status | s | ) |
Is status available?
| s | Input file status. |
Definition at line 697 of file PathV2.cpp.
References llvm::sys::fs::file_type::status_error, and llvm::sys::fs::file_status::type().
Referenced by exists().
| 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. |
| error_code llvm::sys::fs::unique_file | ( | const Twine & | model, |
| int & | result_fd, | ||
| SmallVectorImpl< char > & | result_path, | ||
| bool | makeAbsolute = true, |
||
| unsigned | mode = 0600 |
||
| ) |
Generate a unique path and open it as a 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.
This is an atomic operation. Either the file is created and opened, or the file system is left untouched.
clang-%%-%%-%%-%%-%%.s => /tmp/clang-a0-b1-c2-d3-e4.s
| model | Name to base unique path off of. |
| result_fd | Set to the opened file's file descriptor. |
| result_path | Set to the opened file's absolute path. |
| makeAbsolute | If true and model is not an absolute path, a temp directory will be prepended. |
Referenced by llvm::FileOutputBuffer::create(), and llvm::LockFileManager::LockFileManager().
| error_code llvm::sys::fs::unmap_file_pages | ( | void * | base, |
| size_t | size | ||
| ) |
Memory unmaps the contents of a file.
| base | Pointer to the start of the buffer. |
| size | Byte length of the range to unmmap. |