LLDB  mainline
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
lldb_private::FileSystem Class Reference

#include <FileSystem.h>

Collaboration diagram for lldb_private::FileSystem:
Collaboration graph
[legend]

Public Types

enum  EnumerateDirectoryResult { eEnumerateDirectoryResultNext, eEnumerateDirectoryResultEnter, eEnumerateDirectoryResultQuit }
 
typedef EnumerateDirectoryResult(* EnumerateDirectoryCallbackType) (void *baton, llvm::sys::fs::file_type file_type, llvm::StringRef)
 
typedef std::function< EnumerateDirectoryResult(llvm::sys::fs::file_type file_type, llvm::StringRef)> DirectoryCallback
 

Public Member Functions

 FileSystem ()
 
 FileSystem (FileCollector &collector)
 
 FileSystem (llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > fs, bool mapped=false)
 
 FileSystem (const FileSystem &fs)=delete
 
FileSystemoperator= (const FileSystem &fs)=delete
 
Status Symlink (const FileSpec &src, const FileSpec &dst)
 
Status Readlink (const FileSpec &src, FileSpec &dst)
 
Status ResolveSymbolicLink (const FileSpec &src, FileSpec &dst)
 
FILE * Fopen (const char *path, const char *mode)
 Wraps ::fopen in a platform-independent way. More...
 
int Open (const char *path, int flags, int mode)
 Wraps ::open in a platform-independent way. More...
 
Status Open (File &File, const FileSpec &file_spec, uint32_t options, uint32_t permissions=lldb::eFilePermissionsFileDefault, bool should_close_fd=true)
 
bool ResolveExecutableLocation (FileSpec &file_spec)
 Call into the Host to see if it can help find the file. More...
 
void EnumerateDirectory (llvm::Twine path, bool find_directories, bool find_files, bool find_other, EnumerateDirectoryCallbackType callback, void *callback_baton)
 
std::error_code GetRealPath (const llvm::Twine &path, llvm::SmallVectorImpl< char > &output) const
 
llvm::ErrorOr< std::string > GetExternalPath (const llvm::Twine &path)
 
llvm::ErrorOr< std::string > GetExternalPath (const FileSpec &file_spec)
 
llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > GetVirtualFileSystem ()
 
llvm::vfs::directory_iterator DirBegin (const FileSpec &file_spec, std::error_code &ec)
 Get a directory iterator. More...
 
llvm::vfs::directory_iterator DirBegin (const llvm::Twine &dir, std::error_code &ec)
 
llvm::ErrorOr< llvm::vfs::Status > GetStatus (const FileSpec &file_spec) const
 Returns the Status object for the given file. More...
 
llvm::ErrorOr< llvm::vfs::Status > GetStatus (const llvm::Twine &path) const
 
llvm::sys::TimePoint GetModificationTime (const FileSpec &file_spec) const
 Returns the modification time of the given file. More...
 
llvm::sys::TimePoint GetModificationTime (const llvm::Twine &path) const
 
uint64_t GetByteSize (const FileSpec &file_spec) const
 Returns the on-disk size of the given file in bytes. More...
 
uint64_t GetByteSize (const llvm::Twine &path) const
 
uint32_t GetPermissions (const FileSpec &file_spec) const
 Return the current permissions of the given file. More...
 
uint32_t GetPermissions (const llvm::Twine &path) const
 
uint32_t GetPermissions (const FileSpec &file_spec, std::error_code &ec) const
 
uint32_t GetPermissions (const llvm::Twine &path, std::error_code &ec) const
 
bool Exists (const FileSpec &file_spec) const
 Returns whether the given file exists. More...
 
bool Exists (const llvm::Twine &path) const
 
bool Readable (const FileSpec &file_spec) const
 Returns whether the given file is readable. More...
 
bool Readable (const llvm::Twine &path) const
 
bool IsDirectory (const FileSpec &file_spec) const
 Returns whether the given path is a directory. More...
 
bool IsDirectory (const llvm::Twine &path) const
 
bool IsLocal (const FileSpec &file_spec) const
 Returns whether the given path is local to the file system. More...
 
bool IsLocal (const llvm::Twine &path) const
 
std::error_code MakeAbsolute (llvm::SmallVectorImpl< char > &path) const
 Make the given file path absolute. More...
 
std::error_code MakeAbsolute (FileSpec &file_spec) const
 
void Resolve (llvm::SmallVectorImpl< char > &path)
 Resolve path to make it canonical. More...
 
void Resolve (FileSpec &file_spec)
 
std::shared_ptr< DataBufferLLVMCreateDataBuffer (const llvm::Twine &path, uint64_t size=0, uint64_t offset=0)
 Create memory buffer from path. More...
 
std::shared_ptr< DataBufferLLVMCreateDataBuffer (const FileSpec &file_spec, uint64_t size=0, uint64_t offset=0)
 

Static Public Member Functions

static FileSystemInstance ()
 
static void Initialize ()
 
static void Initialize (FileCollector &collector)
 
static llvm::Error Initialize (const FileSpec &mapping)
 
static void Initialize (llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > fs)
 
static void Terminate ()
 

Static Public Attributes

static const char * DEV_NULL = "/dev/null"
 
static const char * PATH_CONVERSION_ERROR
 

Detailed Description

Definition at line 29 of file FileSystem.h.

Member Typedef Documentation

◆ DirectoryCallback

typedef std::function<EnumerateDirectoryResult( llvm::sys::fs::file_type file_type, llvm::StringRef)> lldb_private::FileSystem::DirectoryCallback

Definition at line 171 of file FileSystem.h.

◆ EnumerateDirectoryCallbackType

typedef EnumerateDirectoryResult(* lldb_private::FileSystem::EnumerateDirectoryCallbackType) (void *baton, llvm::sys::fs::file_type file_type, llvm::StringRef)

Definition at line 166 of file FileSystem.h.

Member Enumeration Documentation

◆ EnumerateDirectoryResult

Enumerator
eEnumerateDirectoryResultNext 

Enumerate next entry in the current directory.

eEnumerateDirectoryResultEnter 

Recurse into the current entry if it is a directory or symlink, or next if not.

eEnumerateDirectoryResultQuit 

Stop directory enumerations at any level.

Definition at line 156 of file FileSystem.h.

Constructor & Destructor Documentation

◆ FileSystem() [1/4]

lldb_private::FileSystem::FileSystem ( )
inline

Definition at line 34 of file FileSystem.h.

Referenced by FileSystem().

◆ FileSystem() [2/4]

lldb_private::FileSystem::FileSystem ( FileCollector collector)
inline

Definition at line 37 of file FileSystem.h.

◆ FileSystem() [3/4]

lldb_private::FileSystem::FileSystem ( llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem >  fs,
bool  mapped = false 
)
inline

◆ FileSystem() [4/4]

lldb_private::FileSystem::FileSystem ( const FileSystem fs)
delete

Member Function Documentation

◆ CreateDataBuffer() [1/2]

std::shared_ptr< DataBufferLLVM > FileSystem::CreateDataBuffer ( const llvm::Twine &  path,
uint64_t  size = 0,
uint64_t  offset = 0 
)

◆ CreateDataBuffer() [2/2]

std::shared_ptr< DataBufferLLVM > FileSystem::CreateDataBuffer ( const FileSpec file_spec,
uint64_t  size = 0,
uint64_t  offset = 0 
)

Definition at line 304 of file common/FileSystem.cpp.

References lldb_private::FileSpec::GetPath().

◆ DirBegin() [1/2]

vfs::directory_iterator FileSystem::DirBegin ( const FileSpec file_spec,
std::error_code &  ec 
)

Get a directory iterator.

Definition at line 87 of file common/FileSystem.cpp.

References lldb_private::FileSpec::GetPath().

Referenced by FileSystem().

◆ DirBegin() [2/2]

llvm::vfs::directory_iterator lldb_private::FileSystem::DirBegin ( const llvm::Twine &  dir,
std::error_code &  ec 
)

◆ EnumerateDirectory()

void FileSystem::EnumerateDirectory ( llvm::Twine  path,
bool  find_directories,
bool  find_files,
bool  find_other,
EnumerateDirectoryCallbackType  callback,
void *  callback_baton 
)

◆ Exists() [1/2]

bool FileSystem::Exists ( const FileSpec file_spec) const

◆ Exists() [2/2]

bool lldb_private::FileSystem::Exists ( const llvm::Twine &  path) const

◆ Fopen()

FILE * FileSystem::Fopen ( const char *  path,
const char *  mode 
)

Wraps ::fopen in a platform-independent way.

Definition at line 74 of file posix/FileSystem.cpp.

Referenced by FileSystem(), and lldb_private::Instruction::TestEmulation().

◆ GetByteSize() [1/2]

uint64_t FileSystem::GetByteSize ( const FileSpec file_spec) const

Returns the on-disk size of the given file in bytes.

Definition at line 118 of file common/FileSystem.cpp.

References lldb_private::FileSpec::GetPath().

Referenced by FileSystem(), and lldb_private::Module::GetObjectFile().

◆ GetByteSize() [2/2]

uint64_t lldb_private::FileSystem::GetByteSize ( const llvm::Twine &  path) const

◆ GetExternalPath() [1/2]

ErrorOr< std::string > FileSystem::GetExternalPath ( const llvm::Twine &  path)

Definition at line 443 of file common/FileSystem.cpp.

Referenced by ShouldLaunchUsingXPC().

◆ GetExternalPath() [2/2]

ErrorOr< std::string > FileSystem::GetExternalPath ( const FileSpec file_spec)

Definition at line 464 of file common/FileSystem.cpp.

References lldb_private::FileSpec::GetPath().

◆ GetModificationTime() [1/2]

sys::TimePoint FileSystem::GetModificationTime ( const FileSpec file_spec) const

◆ GetModificationTime() [2/2]

llvm::sys::TimePoint lldb_private::FileSystem::GetModificationTime ( const llvm::Twine &  path) const

◆ GetPermissions() [1/4]

uint32_t FileSystem::GetPermissions ( const FileSpec file_spec) const

Return the current permissions of the given file.

Returns a bitmask for the current permissions of the file (zero or more of the permission bits defined in File::Permissions).

Definition at line 129 of file common/FileSystem.cpp.

References lldb_private::FileSpec::GetPath(), and GetPermissions().

Referenced by FileSystem(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_vFile_Mode(), and lldb_private::Platform::Install().

◆ GetPermissions() [2/4]

uint32_t lldb_private::FileSystem::GetPermissions ( const llvm::Twine &  path) const

◆ GetPermissions() [3/4]

uint32_t FileSystem::GetPermissions ( const FileSpec file_spec,
std::error_code &  ec 
) const

Definition at line 133 of file common/FileSystem.cpp.

References lldb_private::FileSpec::GetPath(), and GetPermissions().

◆ GetPermissions() [4/4]

uint32_t lldb_private::FileSystem::GetPermissions ( const llvm::Twine &  path,
std::error_code &  ec 
) const

◆ GetRealPath()

std::error_code FileSystem::GetRealPath ( const llvm::Twine &  path,
llvm::SmallVectorImpl< char > &  output 
) const

Definition at line 235 of file common/FileSystem.cpp.

◆ GetStatus() [1/2]

llvm::ErrorOr< vfs::Status > FileSystem::GetStatus ( const FileSpec file_spec) const

Returns the Status object for the given file.

Definition at line 98 of file common/FileSystem.cpp.

References lldb_private::FileSpec::GetPath().

Referenced by FileSystem().

◆ GetStatus() [2/2]

llvm::ErrorOr<llvm::vfs::Status> lldb_private::FileSystem::GetStatus ( const llvm::Twine &  path) const

◆ GetVirtualFileSystem()

llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> lldb_private::FileSystem::GetVirtualFileSystem ( )
inline

Definition at line 184 of file FileSystem.h.

◆ Initialize() [1/4]

void FileSystem::Initialize ( )
static

Definition at line 47 of file common/FileSystem.cpp.

References lldbassert.

Referenced by FileSystem(), and lldb_private::SystemInitializerCommon::Initialize().

◆ Initialize() [2/4]

void FileSystem::Initialize ( FileCollector collector)
static

Definition at line 52 of file common/FileSystem.cpp.

References lldbassert.

◆ Initialize() [3/4]

llvm::Error FileSystem::Initialize ( const FileSpec mapping)
static

Definition at line 57 of file common/FileSystem.cpp.

References lldb_private::FileSpec::GetPath(), and lldbassert.

◆ Initialize() [4/4]

static void lldb_private::FileSystem::Initialize ( llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem >  fs)
static

◆ Instance()

FileSystem & FileSystem::Instance ( )
static

Definition at line 45 of file common/FileSystem.cpp.

Referenced by lldb_private::process_gdb_remote::ProcessGDBRemote::BuildDynamicRegisterInfo(), ProcessElfCore::CanDebug(), lldb_private::ProcessWindows::CanDebug(), lldb_private::ClangExpressionParser::ClangExpressionParser(), lldb_private::ComputeClangResourceDirectory(), lldb_private::HostInfoMacOSX::ComputeSupportExeDirectory(), lldb_private::HostInfoLinux::ComputeSupportExeDirectory(), lldb_private::HostInfoLinux::ComputeSystemPluginsDirectory(), lldb_private::HostInfoAndroid::ComputeTempFileBaseDirectory(), lldb_private::HostInfoMacOSX::ComputeUserPluginsDirectory(), SymbolFileDWARFDwp::Create(), lldb_private::ClangModulesDeclVendor::Create(), ProcessElfCore::CreateInstance(), lldb_private::RemoteAwarePlatform::CreateSymlink(), DefaultComputeClangResourceDirectory(), DiskFilesOrDirectories(), lldb_private::ProcessWindows::DoLaunch(), lldb_private::ScriptInterpreterPythonImpl::ExecuteOneLine(), lldb_private::SourceManager::File::File(), lldb_private::Module::FileHasChanged(), FileSystem(), lldb_private::PathMappingList::FindFile(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::FindModuleFile(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::FindModuleFile(), lldb_private::DynamicLoaderDarwin::FindTargetModuleForImageInfo(), lldb_private::SourceManager::GetFile(), lldb_private::OptionValueFileSpec::GetFileContents(), lldb_private::RemoteAwarePlatform::GetFileExists(), lldb_private::ClangASTContext::getFileManager(), lldb_private::HostProcessPosix::GetMainModule(), lldb_private::Module::GetObjectFile(), lldb_private::ModuleList::GetSharedModule(), lldb_private::platform_android::AdbClient::GetSyncService(), lldb_private::DynamicLoader::GetTargetExecutable(), lldb_private::Platform::GetWorkingDirectory(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_qPlatform_shell(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_vFile_Mode(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_vFile_Open(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_vFile_symlink(), lldb_private::CommandInterpreter::HandleCommandsFromFile(), lldb_private::ClangHighlighter::Highlight(), lldb_private::PluginManager::Initialize(), lldb_private::Platform::Install(), lldb_private::Debugger::InstanceInitialize(), lldb_private::REPL::IOHandlerInputComplete(), lldb_private::Process::Launch(), lldb_private::MonitoringProcessLauncher::LaunchProcess(), lldb_private::process_gdb_remote::ProcessGDBRemote::LoadModules(), LoadPluginCallback(), lldb_private::ScriptInterpreterPythonImpl::LoadPluginModule(), lldb_private::ScriptInterpreterPythonImpl::LoadScriptingModule(), lldb_private::Module::LoadScriptingResourceInTarget(), lldb_private::ObjectFile::MapFileData(), lldb_private::Module::Module(), lldb_private::ProcessWindows::OnDebuggerConnected(), lldb_private::Property::Property(), lldb_private::Platform::PutFile(), lldb_private::PythonFile::PythonFile(), lldb_private::minidump::ProcessMinidump::ReadModuleList(), RecurseCopy_Callback(), lldb_private::PlatformWindows::ResolveExecutable(), lldb_private::Platform::ResolveExecutable(), lldb_private::HostInfoAndroid::ResolveLibraryPath(), lldb_private::Platform::ResolveRemotePath(), lldb_private::Platform::ResolveSymbolFile(), lldb_private::Module::SetFileSpecAndObjectName(), lldb_private::ProcessLaunchInfo::SetShell(), lldb_private::Module::SetSymbolFileFileSpec(), lldb_private::OptionValueFileSpec::SetValueFromString(), lldb_private::CommandInterpreter::SourceInitFile(), lldb_private::ObjectFile::SplitArchivePathWithObject(), lldb_private::process_gdb_remote::GDBRemoteCommunication::StartDebugserverProcess(), lldb_private::StreamFile::StreamFile(), lldb_private::Instruction::TestEmulation(), lldb_private::SourceManager::File::UpdateIfNeeded(), and VerifyClangPath().

◆ IsDirectory() [1/2]

bool FileSystem::IsDirectory ( const FileSpec file_spec) const

Returns whether the given path is a directory.

Definition at line 174 of file common/FileSystem.cpp.

References lldb_private::FileSpec::GetPath().

Referenced by FileSystem().

◆ IsDirectory() [2/2]

bool lldb_private::FileSystem::IsDirectory ( const llvm::Twine &  path) const

◆ IsLocal() [1/2]

bool FileSystem::IsLocal ( const FileSpec file_spec) const

Returns whether the given path is local to the file system.

Definition at line 184 of file common/FileSystem.cpp.

References lldb_private::FileSpec::GetPath().

Referenced by FileSystem().

◆ IsLocal() [2/2]

bool lldb_private::FileSystem::IsLocal ( const llvm::Twine &  path) const

◆ MakeAbsolute() [1/2]

std::error_code FileSystem::MakeAbsolute ( llvm::SmallVectorImpl< char > &  path) const

Make the given file path absolute.

Definition at line 218 of file common/FileSystem.cpp.

Referenced by FileSystem().

◆ MakeAbsolute() [2/2]

std::error_code FileSystem::MakeAbsolute ( FileSpec file_spec) const

◆ Open() [1/2]

int FileSystem::Open ( const char *  path,
int  flags,
int  mode 
)

◆ Open() [2/2]

Status FileSystem::Open ( File File,
const FileSpec file_spec,
uint32_t  options,
uint32_t  permissions = lldb::eFilePermissionsFileDefault,
bool  should_close_fd = true 
)

◆ operator=()

FileSystem& lldb_private::FileSystem::operator= ( const FileSystem fs)
delete

Referenced by FileSystem().

◆ Readable() [1/2]

bool FileSystem::Readable ( const FileSpec file_spec) const

Returns whether the given file is readable.

Definition at line 163 of file common/FileSystem.cpp.

References lldb_private::FileSpec::GetPath().

Referenced by FileSystem(), and lldb_private::PlatformWindows::ResolveExecutable().

◆ Readable() [2/2]

bool lldb_private::FileSystem::Readable ( const llvm::Twine &  path) const

◆ Readlink()

Status FileSystem::Readlink ( const FileSpec src,
FileSpec dst 
)

◆ Resolve() [1/2]

void FileSystem::Resolve ( llvm::SmallVectorImpl< char > &  path)

Resolve path to make it canonical.

Definition at line 240 of file common/FileSystem.cpp.

References lldb_private::TildeExpressionResolver::ResolveFullPath().

Referenced by lldb_private::process_gdb_remote::ProcessGDBRemote::BuildDynamicRegisterInfo(), lldb_private::ComputeClangResourceDirectory(), lldb_private::HostInfoMacOSX::ComputeSupportExeDirectory(), lldb_private::HostInfoLinux::ComputeSystemPluginsDirectory(), lldb_private::HostInfoMacOSX::ComputeUserPluginsDirectory(), DefaultComputeClangResourceDirectory(), lldb_private::ProcessWindows::DoLaunch(), FileSystem(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::FindModuleFile(), lldb_private::ModuleList::GetSharedModule(), lldb_private::Platform::GetWorkingDirectory(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_qPlatform_shell(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_vFile_Mode(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_vFile_Open(), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::Handle_vFile_symlink(), lldb_private::MonitoringProcessLauncher::LaunchProcess(), lldb_private::process_gdb_remote::ProcessGDBRemote::LoadModules(), LoadPluginCallback(), lldb_private::ScriptInterpreterPythonImpl::LoadScriptingModule(), lldb_private::ProcessWindows::OnDebuggerConnected(), lldb_private::Property::Property(), lldb_private::minidump::ProcessMinidump::ReadModuleList(), lldb_private::PlatformWindows::ResolveExecutable(), lldb_private::HostInfoAndroid::ResolveLibraryPath(), lldb_private::Platform::ResolveRemotePath(), lldb_private::OptionValueFileSpec::SetValueFromString(), and lldb_private::CommandInterpreter::SourceInitFile().

◆ Resolve() [2/2]

void FileSystem::Resolve ( FileSpec file_spec)

◆ ResolveExecutableLocation()

bool FileSystem::ResolveExecutableLocation ( FileSpec file_spec)

◆ ResolveSymbolicLink()

Status FileSystem::ResolveSymbolicLink ( const FileSpec src,
FileSpec dst 
)

◆ Symlink()

Status FileSystem::Symlink ( const FileSpec src,
const FileSpec dst 
)

◆ Terminate()

void FileSystem::Terminate ( )
static

Definition at line 77 of file common/FileSystem.cpp.

References lldbassert.

Referenced by FileSystem(), and lldb_private::SystemInitializerCommon::Terminate().

Member Data Documentation

◆ DEV_NULL

const char * FileSystem::DEV_NULL = "/dev/null"
static

◆ PATH_CONVERSION_ERROR

const char * FileSystem::PATH_CONVERSION_ERROR
static
Initial value:
=
"Error converting path between UTF-8 and native encoding"

Definition at line 32 of file FileSystem.h.


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