-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathfs_memory_folder.hpp
More file actions
49 lines (33 loc) · 1.2 KB
/
fs_memory_folder.hpp
File metadata and controls
49 lines (33 loc) · 1.2 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
48
49
#pragma once
#include "fs/api/enums/fs_item_type.hpp"
#include <functional>
#include <memory>
#include <string>
#include <unordered_map>
//------------------------------------------------------------------------------
namespace fs::memory
{
class MemoryFile;
//------------------------------------------------------------------------------
class MemoryFolder
{
public:
using FolderPtr = std::shared_ptr< MemoryFolder >;
using FilePtr = std::shared_ptr< MemoryFile >;
using ItemCallback = std::function< void( std::string_view, ItemType ) >;
MemoryFolder( std::string_view _name );
FolderPtr ensureSubFolder( std::string_view _name );
FolderPtr getSubFolder( std::string_view _name ) const;
FilePtr ensureFile( std::string_view _name );
FilePtr getFile( std::string_view _name ) const;
void forEachItem( const ItemCallback & _callback );
private:
using SubFolders = std::unordered_map< std::string, FolderPtr >;
using Files = std::unordered_map< std::string, FilePtr >;
SubFolders m_subdirs;
Files m_files;
const std::string m_name;
};
//------------------------------------------------------------------------------
}
//------------------------------------------------------------------------------