@@ -25,9 +25,9 @@ class IFileArchive : public core::IReferenceCounted
25
25
enum E_ALLOCATOR_TYPE
26
26
{
27
27
EAT_NONE = 0 ,
28
- EAT_NULL,
29
- EAT_VIRTUAL_ALLOC,
30
- EAT_MALLOC
28
+ EAT_NULL, // read directly from archive's underlying mapped file
29
+ EAT_VIRTUAL_ALLOC, // decompress to RAM (with sparse paging)
30
+ EAT_MALLOC // decompress to RAM
31
31
};
32
32
// ! An entry in a list of items, can be a folder or a file.
33
33
struct SListEntry
@@ -38,13 +38,11 @@ class IFileArchive : public core::IReferenceCounted
38
38
// ! The size of the file in bytes
39
39
size_t size;
40
40
41
- // ! The ID of the file in an archive
42
- /* * This is used to link the FileList entry to extra info held about this
43
- file in an archive, which can hold things like data offset and CRC. */
44
- uint32_t ID;
45
-
46
41
// ! FileOffset inside an archive
47
- uint32_t offset;
42
+ size_t offset;
43
+
44
+ // ! The ID of the file in an archive, it maps it to a memory pool entry for CFileView
45
+ uint32_t ID;
48
46
49
47
// `EAT_NONE` for directories
50
48
E_ALLOCATOR_TYPE allocatorType;
@@ -77,28 +75,17 @@ class IFileArchive : public core::IReferenceCounted
77
75
protected:
78
76
IFileArchive (path&& _defaultAbsolutePath, system::logger_opt_smart_ptr&& logger) :
79
77
m_defaultAbsolutePath (std::move(_defaultAbsolutePath)), m_logger(std::move(logger)) {}
80
- /*
81
- virtual void addItem(const system::path& fullPath, uint32_t offset, uint32_t size, E_ALLOCATOR_TYPE allocatorType, uint32_t id = 0)
82
- {
83
- SFileListEntry entry;
84
- entry.ID = id ? id : m_items.size();
85
- entry.offset = offset;
86
- entry.size = size;
87
- entry.name = fullPath;
88
- entry.allocatorType = allocatorType;
89
- entry.fullName = entry.name;
90
-
91
- core::deletePathFromFilename(entry.name);
92
78
93
- m_items.insert(std::lower_bound(m_items.begin(), m_items.end(), entry), entry);
94
- }
95
- */
96
- inline uint32_t getIndexFromPath (const system::path& pathRelativeToArchive) const
79
+ inline const SListEntry* getItemFromPath (const system::path& pathRelativeToArchive) const
97
80
{
98
81
const IFileArchive::SListEntry itemToFind = { pathRelativeToArchive };
99
- return std::distance (m_items.begin (),std::lower_bound (m_items.begin (),m_items.end (),itemToFind));
82
+ const auto found = std::lower_bound (m_items.begin (),m_items.end (),itemToFind);
83
+ if (found!=m_items.end () || found->pathRelativeToArchive !=pathRelativeToArchive)
84
+ return nullptr ;
85
+ return &(*found);
100
86
}
101
87
88
+ std::mutex itemMutex; // TODO: update to readers writer lock
102
89
path m_defaultAbsolutePath;
103
90
// files and directories
104
91
core::vector<SListEntry> m_items;
0 commit comments