-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathDirectory.h
59 lines (41 loc) · 1.24 KB
/
Directory.h
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
50
51
52
53
54
55
56
57
58
59
/*
* Directory.h
*
* Created on: Aug 22, 2021
* Author: <a href="mailto:damirlj@yahoo.com">Damir Ljubic</a>
*/
#ifndef DS_FILES_DIRECTORY_H_
#define DS_FILES_DIRECTORY_H_
#include <filesystem>
#include <list>
#include <future>
#include "../AOT/AOThread_v2.h"
namespace utils::files
{
class Directory final
{
public:
using entry_t = std::filesystem::directory_entry;
using entries_t = std::list<entry_t>;
using path_t = std::filesystem::path;
explicit Directory(path_t root) noexcept;
~Directory();
std::future<void> forceSync();
entries_t getSubdirectories();
entries_t getAllFiles();
private:
/**
* Cache the entries (directories/files) into memory
*/
std::future<void> sync();
void getAllEntries(std::filesystem::path root);
private:
std::filesystem::path m_root;
entries_t m_directories;
entries_t m_files;
std::once_flag m_syncOnce;
std::unique_ptr<utils::aot::AOThread> m_pSyncThread;
};
void printDirectoryEntries(Directory& directory);
}
#endif /* DS_FILES_DIRECTORY_H_ */