Go to the documentation of this file.
9 #ifndef LLDB_HOST_FILESYSTEM_H
10 #define LLDB_HOST_FILESYSTEM_H
17 #include "llvm/ADT/Optional.h"
18 #include "llvm/Support/Chrono.h"
19 #include "llvm/Support/VirtualFileSystem.h"
34 FileSystem(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> fs)
35 :
m_fs(std::move(fs)) {}
43 static void Initialize(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> fs);
52 FILE *
Fopen(
const char *path,
const char *mode);
55 int Open(
const char *path,
int flags,
int mode);
57 llvm::Expected<std::unique_ptr<File>>
59 uint32_t permissions = lldb::eFilePermissionsFileDefault,
60 bool should_close_fd =
true);
66 llvm::vfs::directory_iterator
DirBegin(
const llvm::Twine &dir,
73 llvm::ErrorOr<llvm::vfs::Status>
GetStatus(
const llvm::Twine &path)
const;
85 uint64_t
GetByteSize(
const llvm::Twine &path)
const;
102 bool Exists(
const llvm::Twine &path)
const;
108 bool Readable(
const llvm::Twine &path)
const;
120 bool IsLocal(
const llvm::Twine &path)
const;
147 uint64_t offset = 0);
150 uint64_t offset = 0);
151 std::shared_ptr<WritableDataBuffer>
153 uint64_t offset = 0);
154 std::shared_ptr<WritableDataBuffer>
156 uint64_t offset = 0);
177 void *baton, llvm::sys::fs::file_type file_type, llvm::StringRef);
180 llvm::sys::fs::file_type file_type, llvm::StringRef)>
184 bool find_files,
bool find_other,
186 void *callback_baton);
188 std::error_code
GetRealPath(
const llvm::Twine &path,
199 llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>
m_fs;
FileSystem(llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > fs)
int Open(const char *path, int flags, int mode)
Wraps ::open in a platform-independent way.
std::shared_ptr< DataBuffer > CreateDataBuffer(const llvm::Twine &path, uint64_t size=0, uint64_t offset=0)
Create memory buffer from path.
std::error_code MakeAbsolute(llvm::SmallVectorImpl< char > &path) const
Make the given file path absolute.
FILE * Fopen(const char *path, const char *mode)
Wraps ::fopen in a platform-independent way.
void SetHomeDirectory(std::string home_directory)
llvm::ErrorOr< llvm::vfs::Status > GetStatus(const FileSpec &file_spec) const
Returns the Status object for the given file.
bool IsDirectory(const FileSpec &file_spec) const
Returns whether the given path is a directory.
bool GetHomeDirectory(llvm::SmallVectorImpl< char > &path) const
Get the user home directory.
bool ResolveExecutableLocation(FileSpec &file_spec)
Call into the Host to see if it can help find the file.
bool Exists(const FileSpec &file_spec) const
Returns whether the given file exists.
static const char * DEV_NULL
std::string m_home_directory
Status ResolveSymbolicLink(const FileSpec &src, FileSpec &dst)
bool IsLocal(const FileSpec &file_spec) const
Returns whether the given path is local to the file system.
uint64_t GetByteSize(const FileSpec &file_spec) const
Returns the on-disk size of the given file in bytes.
FileSystem & operator=(const FileSystem &fs)=delete
llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > m_fs
std::function< EnumerateDirectoryResult(llvm::sys::fs::file_type file_type, llvm::StringRef)> DirectoryCallback
@ eEnumerateDirectoryResultQuit
Stop directory enumerations at any level.
llvm::sys::TimePoint GetModificationTime(const FileSpec &file_spec) const
Returns the modification time of the given file.
string(SUBSTRING ${p} 10 -1 pStripped) if($
void Resolve(llvm::SmallVectorImpl< char > &path)
Resolve path to make it canonical.
Status Readlink(const FileSpec &src, FileSpec &dst)
EnumerateDirectoryResult(* EnumerateDirectoryCallbackType)(void *baton, llvm::sys::fs::file_type file_type, llvm::StringRef)
Status RemoveFile(const FileSpec &file_spec)
Remove a single file.
@ eEnumerateDirectoryResultNext
Enumerate next entry in the current directory.
std::shared_ptr< WritableDataBuffer > CreateWritableDataBuffer(const llvm::Twine &path, uint64_t size=0, uint64_t offset=0)
llvm::vfs::directory_iterator DirBegin(const FileSpec &file_spec, std::error_code &ec)
Get a directory iterator.
@ eEnumerateDirectoryResultEnter
Recurse into the current entry if it is a directory or symlink, or next if not.
void EnumerateDirectory(llvm::Twine path, bool find_directories, bool find_files, bool find_other, EnumerateDirectoryCallbackType callback, void *callback_baton)
static const char * PATH_CONVERSION_ERROR
bool Readable(const FileSpec &file_spec) const
Returns whether the given file is readable.
uint32_t GetPermissions(const FileSpec &file_spec) const
Return the current permissions of the given file.
Status Symlink(const FileSpec &src, const FileSpec &dst)
static FileSystem & Instance()
llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > GetVirtualFileSystem()
A class that represents a running process on the host machine.
std::error_code GetRealPath(const llvm::Twine &path, llvm::SmallVectorImpl< char > &output) const
static llvm::Optional< FileSystem > & InstanceImpl()