Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame] | 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 | //===----------------------------------------------------------------------===// |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame^] | 8 | #ifndef LLDB_HOST_FILECACHE_H |
| 9 | #define LLDB_HOST_FILECACHE_H |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame] | 10 | |
| 11 | #include <map> |
| 12 | #include <stdint.h> |
| 13 | |
| 14 | #include "lldb/lldb-forward.h" |
| 15 | #include "lldb/lldb-types.h" |
| 16 | |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame^] | 17 | #include "lldb/Host/File.h" |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame] | 18 | #include "lldb/Utility/FileSpec.h" |
| 19 | #include "lldb/Utility/Status.h" |
| 20 | |
| 21 | namespace lldb_private { |
| 22 | class FileCache { |
| 23 | private: |
| 24 | FileCache() {} |
| 25 | |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame^] | 26 | typedef std::map<lldb::user_id_t, lldb::FileUP> FDToFileMap; |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame] | 27 | |
| 28 | public: |
| 29 | static FileCache &GetInstance(); |
| 30 | |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame^] | 31 | lldb::user_id_t OpenFile(const FileSpec &file_spec, File::OpenOptions flags, |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame] | 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 |