-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathfs_memory_file_system.hpp
More file actions
47 lines (32 loc) · 1.18 KB
/
fs_memory_file_system.hpp
File metadata and controls
47 lines (32 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#pragma once
#include "fs/api/fs_file_system.hpp"
#include "tools/std_hash_fs_path.hpp"
#include <unordered_map>
//------------------------------------------------------------------------------
namespace fs::memory
{
class MemoryFolder;
//------------------------------------------------------------------------------
class MemoryFileSystem final : public FileSystem
{
public:
FilePtr openFile( const Path & _path ) const override;
FilePtr createFile( const Path & _path ) override;
bool isExistFile( const Path & _path ) const override;
void
forEachItem( const Path & _dirPath, ItemCallback _callback ) const override;
Path getCurrentPath() const override;
Path toAbsolute( const Path & _path ) const override;
private:
using FolderPtr = std::shared_ptr< MemoryFolder >;
FolderPtr getRoot( const Path & _path ) const;
MemoryFolder & ensureRoot( const Path & _path );
FolderPtr getFolder( const Path & _path ) const;
MemoryFolder & ensureFolder( const Path & _path );
Path toAbsolutePath( const Path & _path ) const;
private:
using Roots = std::unordered_map< Path, FolderPtr >;
Roots m_roots;
};
//------------------------------------------------------------------------------
}