30 error.SetErrorString(
"empty path");
35 error = file.takeError();
39 m_cache[fd] = std::move(file.get());
45 error.SetErrorString(
"invalid file descriptor");
48 FDToFileMap::iterator pos =
m_cache.find(fd);
50 error.SetErrorStringWithFormat(
"invalid host file descriptor %" PRIu64, fd);
53 FileUP &file_up = pos->second;
55 error.SetErrorString(
"invalid host backing file");
58 error = file_up->Close();
60 return error.Success();
64 const void *src, uint64_t src_len,
67 error.SetErrorString(
"invalid file descriptor");
70 FDToFileMap::iterator pos =
m_cache.find(fd);
72 error.SetErrorStringWithFormat(
"invalid host file descriptor %" PRIu64, fd);
75 FileUP &file_up = pos->second;
77 error.SetErrorString(
"invalid host backing file");
80 if (
static_cast<uint64_t
>(file_up->SeekFromStart(offset, &
error)) != offset ||
83 size_t bytes_written = src_len;
84 error = file_up->Write(src, bytes_written);
93 error.SetErrorString(
"invalid file descriptor");
96 FDToFileMap::iterator pos =
m_cache.find(fd);
98 error.SetErrorStringWithFormat(
"invalid host file descriptor %" PRIu64, fd);
101 FileUP &file_up = pos->second;
103 error.SetErrorString(
"invalid host backing file");
106 if (
static_cast<uint64_t
>(file_up->SeekFromStart(offset, &
error)) != offset ||
109 size_t bytes_read = dst_len;
110 error = file_up->Read(dst, bytes_read);
static llvm::raw_ostream & error(Stream &strm)
bool CloseFile(lldb::user_id_t fd, Status &error)
uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst, uint64_t dst_len, Status &error)
lldb::user_id_t OpenFile(const FileSpec &file_spec, File::OpenOptions flags, uint32_t mode, Status &error)
uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src, uint64_t src_len, Status &error)
static FileCache * m_instance
static FileCache & GetInstance()
int Open(const char *path, int flags, int mode=0600)
Wraps ::open in a platform-independent way.
static FileSystem & Instance()
A class that represents a running process on the host machine.
std::unique_ptr< lldb_private::File > FileUP