1 //===-- FileCache.h ---------------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 #ifndef liblldb_Host_FileCache_h
10 #define liblldb_Host_FileCache_h
11 
12 #include <map>
13 #include <stdint.h>
14 
15 #include "lldb/lldb-forward.h"
16 #include "lldb/lldb-types.h"
17 
18 #include "lldb/Utility/FileSpec.h"
19 #include "lldb/Utility/Status.h"
20 
21 namespace lldb_private {
22 class FileCache {
23 private:
FileCache()24   FileCache() {}
25 
26   typedef std::map<lldb::user_id_t, lldb::FileSP> FDToFileMap;
27 
28 public:
29   static FileCache &GetInstance();
30 
31   lldb::user_id_t OpenFile(const FileSpec &file_spec, uint32_t flags,
32                            uint32_t mode, Status &error);
33   bool CloseFile(lldb::user_id_t fd, Status &error);
34 
35   uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src,
36                      uint64_t src_len, Status &error);
37   uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst,
38                     uint64_t dst_len, Status &error);
39 
40 private:
41   static FileCache *m_instance;
42 
43   FDToFileMap m_cache;
44 };
45 }
46 
47 #endif
48