39 m_cache[fd] = std::move(file.get());
48 FDToFileMap::iterator pos =
m_cache.find(fd);
51 "invalid host file descriptor %" PRIu64, fd);
54 FileUP &file_up = pos->second;
59 error = file_up->Close();
61 return error.Success();
65 const void *src, uint64_t src_len,
71 FDToFileMap::iterator pos =
m_cache.find(fd);
74 "invalid host file descriptor %" PRIu64, fd);
77 FileUP &file_up = pos->second;
82 if (
static_cast<uint64_t
>(file_up->SeekFromStart(offset, &
error)) != offset ||
85 size_t bytes_written = src_len;
86 error = file_up->Write(src, bytes_written);
98 FDToFileMap::iterator pos =
m_cache.find(fd);
101 "invalid host file descriptor %" PRIu64, fd);
104 FileUP &file_up = pos->second;
109 if (
static_cast<uint64_t
>(file_up->SeekFromStart(offset, &
error)) != offset ||
112 size_t bytes_read = dst_len;
113 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()
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
static Status FromErrorString(const char *str)
static Status FromError(llvm::Error error)
Avoid using this in new code. Migrate APIs to llvm::Expected instead.
A class that represents a running process on the host machine.
std::unique_ptr< lldb_private::File > FileUP