LLDB  mainline
FileCache.h
Go to the documentation of this file.
1 //===-- FileCache.h ---------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 #ifndef liblldb_Host_FileCache_h
9 #define liblldb_Host_FileCache_h
10 
11 #include <map>
12 #include <stdint.h>
13 
14 #include "lldb/lldb-forward.h"
15 #include "lldb/lldb-types.h"
16 
17 #include "lldb/Utility/FileSpec.h"
18 #include "lldb/Utility/Status.h"
19 
20 namespace lldb_private {
21 class FileCache {
22 private:
23  FileCache() {}
24 
25  typedef std::map<lldb::user_id_t, lldb::FileSP> FDToFileMap;
26 
27 public:
28  static FileCache &GetInstance();
29 
30  lldb::user_id_t OpenFile(const FileSpec &file_spec, uint32_t flags,
31  uint32_t mode, Status &error);
32  bool CloseFile(lldb::user_id_t fd, Status &error);
33 
34  uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src,
35  uint64_t src_len, Status &error);
36  uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst,
37  uint64_t dst_len, Status &error);
38 
39 private:
40  static FileCache *m_instance;
41 
42  FDToFileMap m_cache;
43 };
44 }
45 
46 #endif
uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src, uint64_t src_len, Status &error)
Definition: FileCache.cpp:61
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
A file utility class.
Definition: FileSpec.h:55
uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst, uint64_t dst_len, Status &error)
Definition: FileCache.cpp:88
lldb::user_id_t OpenFile(const FileSpec &file_spec, uint32_t flags, uint32_t mode, Status &error)
Definition: FileCache.cpp:26
uint64_t user_id_t
Definition: lldb-types.h:84
static FileCache & GetInstance()
Definition: FileCache.cpp:19
bool CloseFile(lldb::user_id_t fd, Status &error)
Definition: FileCache.cpp:41
An error handling class.
Definition: Status.h:44