LLVM  8.0.1
Classes | Namespaces | Typedefs | Enumerations | Functions | Variables
FileSystem.h File Reference
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/Support/Chrono.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/MD5.h"
#include <cassert>
#include <cstdint>
#include <ctime>
#include <memory>
#include <stack>
#include <string>
#include <system_error>
#include <tuple>
#include <vector>
Include dependency graph for FileSystem.h:

Go to the source code of this file.

Classes

struct  llvm::sys::fs::space_info
 space_info - Self explanatory. More...
 
class  llvm::sys::fs::UniqueID
 
class  llvm::sys::fs::basic_file_status
 Represents the result of a call to directory_iterator::status(). More...
 
class  llvm::sys::fs::file_status
 Represents the result of a call to sys::fs::status(). More...
 
class  llvm::sys::fs::TempFile
 Represents a temporary file. More...
 
class  llvm::sys::fs::mapped_file_region
 This class represents a memory mapped file. More...
 
class  llvm::sys::fs::directory_entry
 directory_entry - A single entry in a directory. More...
 
struct  llvm::sys::fs::detail::DirIterState
 Keeps state for the directory_iterator. More...
 
class  llvm::sys::fs::directory_iterator
 directory_iterator - Iterates through the entries in path. More...
 
struct  llvm::sys::fs::detail::RecDirIterState
 Keeps state for the recursive_directory_iterator. More...
 
class  llvm::sys::fs::recursive_directory_iterator
 recursive_directory_iterator - Same as directory_iterator except for it recurses down into child directories. More...
 

Namespaces

 llvm
 This class represents lattice values for constants.
 
 llvm::sys
 
 llvm::sys::fs
 
 llvm::sys::fs::detail
 

Typedefs

using llvm::sys::fs::file_t = int
 

Enumerations

enum  llvm::sys::fs::file_type {
  llvm::sys::fs::file_type::status_error, llvm::sys::fs::file_type::file_not_found, llvm::sys::fs::file_type::regular_file, llvm::sys::fs::file_type::directory_file,
  llvm::sys::fs::file_type::symlink_file, llvm::sys::fs::file_type::block_file, llvm::sys::fs::file_type::character_file, llvm::sys::fs::file_type::fifo_file,
  llvm::sys::fs::file_type::socket_file, llvm::sys::fs::file_type::type_unknown
}
 An enumeration for the file system's view of the type. More...
 
enum  llvm::sys::fs::perms {
  llvm::sys::fs::no_perms = 0, llvm::sys::fs::owner_read = 0400, llvm::sys::fs::owner_write = 0200, llvm::sys::fs::owner_exe = 0100,
  llvm::sys::fs::owner_all = owner_read | owner_write | owner_exe, llvm::sys::fs::group_read = 040, llvm::sys::fs::group_write = 020, llvm::sys::fs::group_exe = 010,
  llvm::sys::fs::group_all = group_read | group_write | group_exe, llvm::sys::fs::others_read = 04, llvm::sys::fs::others_write = 02, llvm::sys::fs::others_exe = 01,
  llvm::sys::fs::others_all = others_read | others_write | others_exe, llvm::sys::fs::all_read = owner_read | group_read | others_read, llvm::sys::fs::all_write = owner_write | group_write | others_write, llvm::sys::fs::all_exe = owner_exe | group_exe | others_exe,
  llvm::sys::fs::all_all = owner_all | group_all | others_all, llvm::sys::fs::set_uid_on_exe = 04000, llvm::sys::fs::set_gid_on_exe = 02000, llvm::sys::fs::sticky_bit = 01000,
  llvm::sys::fs::all_perms = all_all | set_uid_on_exe | set_gid_on_exe | sticky_bit, llvm::sys::fs::perms_not_known = 0xFFFF
}
 

Functions

perms llvm::sys::fs::operator| (perms l, perms r)
 
perms llvm::sys::fs::operator & (perms l, perms r)
 
perms & llvm::sys::fs::operator|= (perms &l, perms r)
 
perms & llvm::sys::fs::operator &= (perms &l, perms r)
 
perms llvm::sys::fs::operator~ (perms x)
 
std::error_code llvm::sys::fs::detail::directory_iterator_construct (DirIterState &, StringRef, bool)
 
std::error_code llvm::sys::fs::detail::directory_iterator_increment (DirIterState &)
 
std::error_code llvm::sys::fs::detail::directory_iterator_destruct (DirIterState &)
 
Physical Operators
void llvm::sys::fs::make_absolute (const Twine &current_directory, SmallVectorImpl< char > &path)
 Make path an absolute path. More...
 
std::error_code llvm::sys::fs::make_absolute (SmallVectorImpl< char > &path)
 Make path an absolute path. More...
 
std::error_code llvm::sys::fs::create_directories (const Twine &path, bool IgnoreExisting=true, perms Perms=owner_all|group_all)
 Create all the non-existent directories in path. More...
 
std::error_code llvm::sys::fs::create_directory (const Twine &path, bool IgnoreExisting=true, perms Perms=owner_all|group_all)
 Create the directory in path. More...
 
std::error_code llvm::sys::fs::create_link (const Twine &to, const Twine &from)
 Create a link from from to to. More...
 
std::error_code llvm::sys::fs::create_hard_link (const Twine &to, const Twine &from)
 Create a hard link from from to to, or return an error. More...
 
std::error_code llvm::sys::fs::real_path (const Twine &path, SmallVectorImpl< char > &output, bool expand_tilde=false)
 Collapse all . More...
 
void llvm::sys::fs::expand_tilde (const Twine &path, SmallVectorImpl< char > &output)
 Expands ~ expressions to the user's home directory. More...
 
std::error_code llvm::sys::fs::current_path (SmallVectorImpl< char > &result)
 Get the current path. More...
 
std::error_code llvm::sys::fs::set_current_path (const Twine &path)
 Set the current path. More...
 
std::error_code llvm::sys::fs::remove (const Twine &path, bool IgnoreNonExisting=true)
 Remove path. More...
 
std::error_code llvm::sys::fs::remove_directories (const Twine &path, bool IgnoreErrors=true)
 Recursively delete a directory. More...
 
std::error_code llvm::sys::fs::rename (const Twine &from, const Twine &to)
 Rename from to to. More...
 
std::error_code llvm::sys::fs::copy_file (const Twine &From, const Twine &To)
 Copy the contents of From to To. More...
 
std::error_code llvm::sys::fs::copy_file (const Twine &From, int ToFD)
 Copy the contents of From to To. More...
 
std::error_code llvm::sys::fs::resize_file (int FD, uint64_t Size)
 Resize path to size. More...
 
ErrorOr< MD5::MD5Resultllvm::sys::fs::md5_contents (int FD)
 Compute an MD5 hash of a file's contents. More...
 
ErrorOr< MD5::MD5Resultllvm::sys::fs::md5_contents (const Twine &Path)
 Version of compute_md5 that doesn't require an open file descriptor. More...
 

Variables

const file_t llvm::sys::fs::kInvalidFile
 

Physical Observers

enum  llvm::sys::fs::AccessMode { llvm::sys::fs::AccessMode::Exist, llvm::sys::fs::AccessMode::Write, llvm::sys::fs::AccessMode::Execute }
 
enum  llvm::sys::fs::CreationDisposition : unsigned { llvm::sys::fs::CD_CreateAlways = 0, llvm::sys::fs::CD_CreateNew = 1, llvm::sys::fs::CD_OpenExisting = 2, llvm::sys::fs::CD_OpenAlways = 3 }
 
enum  llvm::sys::fs::FileAccess : unsigned { llvm::sys::fs::FA_Read = 1, llvm::sys::fs::FA_Write = 2 }
 
enum  llvm::sys::fs::OpenFlags : unsigned {
  llvm::sys::fs::OF_None = 0, llvm::sys::fs::F_None = 0, llvm::sys::fs::OF_Text = 1, llvm::sys::fs::F_Text = 1,
  llvm::sys::fs::OF_Append = 2, llvm::sys::fs::F_Append = 2, llvm::sys::fs::OF_Delete = 4, llvm::sys::fs::OF_ChildInherit = 8,
  llvm::sys::fs::OF_UpdateAtime = 16
}
 
bool llvm::sys::fs::exists (const basic_file_status &status)
 Does file exist? More...
 
std::error_code llvm::sys::fs::access (const Twine &Path, AccessMode Mode)
 Can the file be accessed? More...
 
bool llvm::sys::fs::exists (const Twine &Path)
 Does file exist? More...
 
bool llvm::sys::fs::can_execute (const Twine &Path)
 Can we execute this file? More...
 
bool llvm::sys::fs::can_write (const Twine &Path)
 Can we write this file? More...
 
bool llvm::sys::fs::equivalent (file_status A, file_status B)
 Do file_status's represent the same thing? More...
 
std::error_code llvm::sys::fs::equivalent (const Twine &A, const Twine &B, bool &result)
 Do paths represent the same thing? More...
 
bool llvm::sys::fs::equivalent (const Twine &A, const Twine &B)
 Simpler version of equivalent for clients that don't need to differentiate between an error and false. More...
 
std::error_code llvm::sys::fs::is_local (const Twine &path, bool &result)
 Is the file mounted on a local filesystem? More...
 
std::error_code llvm::sys::fs::is_local (int FD, bool &result)
 Version of is_local accepting an open file descriptor. More...
 
bool llvm::sys::fs::is_local (const Twine &Path)
 Simpler version of is_local for clients that don't need to differentiate between an error and false. More...
 
bool llvm::sys::fs::is_local (int FD)
 Simpler version of is_local accepting an open file descriptor for clients that don't need to differentiate between an error and false. More...
 
file_type llvm::sys::fs::get_file_type (const Twine &Path, bool Follow=true)
 Does status represent a directory? More...
 
bool llvm::sys::fs::is_directory (const basic_file_status &status)
 Does status represent a directory? More...
 
std::error_code llvm::sys::fs::is_directory (const Twine &path, bool &result)
 Is path a directory? More...
 
bool llvm::sys::fs::is_directory (const Twine &Path)
 Simpler version of is_directory for clients that don't need to differentiate between an error and false. More...
 
bool llvm::sys::fs::is_regular_file (const basic_file_status &status)
 Does status represent a regular file? More...
 
std::error_code llvm::sys::fs::is_regular_file (const Twine &path, bool &result)
 Is path a regular file? More...
 
bool llvm::sys::fs::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. More...
 
bool llvm::sys::fs::is_symlink_file (const basic_file_status &status)
 Does status represent a symlink file? More...
 
std::error_code llvm::sys::fs::is_symlink_file (const Twine &path, bool &result)
 Is path a symlink file? More...
 
bool llvm::sys::fs::is_symlink_file (const Twine &Path)
 Simpler version of is_symlink_file for clients that don't need to differentiate between an error and false. More...
 
bool llvm::sys::fs::is_other (const basic_file_status &status)
 Does this status represent something that exists but is not a directory or regular file? More...
 
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? More...
 
std::error_code llvm::sys::fs::status (const Twine &path, file_status &result, bool follow=true)
 Get file status as if by POSIX stat(). More...
 
std::error_code llvm::sys::fs::status (int FD, file_status &Result)
 A version for when a file descriptor is already available. More...
 
std::error_code llvm::sys::fs::setPermissions (const Twine &Path, perms Permissions)
 Set file permissions. More...
 
ErrorOr< perms > llvm::sys::fs::getPermissions (const Twine &Path)
 Get file permissions. More...
 
std::error_code llvm::sys::fs::file_size (const Twine &Path, uint64_t &Result)
 Get file size. More...
 
std::error_code llvm::sys::fs::setLastAccessAndModificationTime (int FD, TimePoint<> AccessTime, TimePoint<> ModificationTime)
 Set the file modification and access time. More...
 
std::error_code llvm::sys::fs::setLastAccessAndModificationTime (int FD, TimePoint<> Time)
 Simpler version that sets both file modification and access time to the same time. More...
 
bool llvm::sys::fs::status_known (const basic_file_status &s)
 Is status available? More...
 
std::error_code llvm::sys::fs::status_known (const Twine &path, bool &result)
 Is status available? More...
 
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. More...
 
std::error_code llvm::sys::fs::createUniqueFile (const Twine &Model, SmallVectorImpl< char > &ResultPath, unsigned Mode=all_read|all_write)
 Simpler version for clients that don't want an open file. More...
 
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. More...
 
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. More...
 
std::error_code llvm::sys::fs::createUniqueDirectory (const Twine &Prefix, SmallVectorImpl< char > &ResultPath)
 
std::error_code llvm::sys::fs::getPotentiallyUniqueFileName (const Twine &Model, SmallVectorImpl< char > &ResultPath)
 Get a unique name, not currently exisiting in the filesystem. More...
 
std::error_code llvm::sys::fs::getPotentiallyUniqueTempFileName (const Twine &Prefix, StringRef Suffix, SmallVectorImpl< char > &ResultPath)
 Get a unique temporary file name, not currently exisiting in the filesystem. More...
 
OpenFlags llvm::sys::fs::operator| (OpenFlags A, OpenFlags B)
 
OpenFlags & llvm::sys::fs::operator|= (OpenFlags &A, OpenFlags B)
 
FileAccess llvm::sys::fs::operator| (FileAccess A, FileAccess B)
 
FileAccess & llvm::sys::fs::operator|= (FileAccess &A, FileAccess B)
 
std::error_code llvm::sys::fs::openFile (const Twine &Name, int &ResultFD, CreationDisposition Disp, FileAccess Access, OpenFlags Flags, unsigned Mode=0666)
 Opens a file with the specified creation disposition, access mode, and flags and returns a file descriptor. More...
 
Expected< file_t > llvm::sys::fs::openNativeFile (const Twine &Name, CreationDisposition Disp, FileAccess Access, OpenFlags Flags, unsigned Mode=0666)
 Opens a file with the specified creation disposition, access mode, and flags and returns a platform-specific file object. More...
 
std::error_code llvm::sys::fs::openFileForWrite (const Twine &Name, int &ResultFD, CreationDisposition Disp=CD_CreateAlways, OpenFlags Flags=OF_None, unsigned Mode=0666)
 Opens the file with the given name in a write-only or read-write mode, returning its open file descriptor. More...
 
Expected< file_t > llvm::sys::fs::openNativeFileForWrite (const Twine &Name, CreationDisposition Disp, OpenFlags Flags, unsigned Mode=0666)
 Opens the file with the given name in a write-only or read-write mode, returning its open file descriptor. More...
 
std::error_code llvm::sys::fs::openFileForReadWrite (const Twine &Name, int &ResultFD, CreationDisposition Disp, OpenFlags Flags, unsigned Mode=0666)
 Opens the file with the given name in a write-only or read-write mode, returning its open file descriptor. More...
 
Expected< file_t > llvm::sys::fs::openNativeFileForReadWrite (const Twine &Name, CreationDisposition Disp, OpenFlags Flags, unsigned Mode=0666)
 Opens the file with the given name in a write-only or read-write mode, returning its open file descriptor. More...
 
std::error_code llvm::sys::fs::openFileForRead (const Twine &Name, int &ResultFD, OpenFlags Flags=OF_None, SmallVectorImpl< char > *RealPath=nullptr)
 Opens the file with the given name in a read-only mode, returning its open file descriptor. More...
 
Expected< file_t > llvm::sys::fs::openNativeFileForRead (const Twine &Name, OpenFlags Flags=OF_None, SmallVectorImpl< char > *RealPath=nullptr)
 Opens the file with the given name in a read-only mode, returning its open file descriptor. More...
 
void llvm::sys::fs::closeFile (file_t &F)
 Close the file object. More...
 
std::error_code llvm::sys::fs::getUniqueID (const Twine Path, UniqueID &Result)
 
ErrorOr< space_info > llvm::sys::fs::disk_space (const Twine &Path)
 Get disk space usage information. More...
 
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. More...