@@ -32,16 +32,8 @@ class IFileArchive : public core::IReferenceCounted
32
32
// ! An entry in a list of items, can be a folder or a file.
33
33
struct SListEntry
34
34
{
35
- #if 0
36
- //! The name of the file
37
- /** If this is a file or folder in the virtual filesystem and the archive
38
- was created with the ignoreCase flag then the file name will be lower case. */
39
- system::path name;
40
- #endif
41
- // ! The name of the file including the path
42
- /* * If this is a file or folder in the virtual filesystem and the archive was
43
- created with the ignoreDirs flag then it will be the same as Name. */
44
- system::path fullName;
35
+ // ! The name of the file including the path relative to archive root
36
+ system::path pathRelativeToArchive;
45
37
46
38
// ! The size of the file in bytes
47
39
size_t size;
@@ -58,15 +50,15 @@ class IFileArchive : public core::IReferenceCounted
58
50
E_ALLOCATOR_TYPE allocatorType;
59
51
60
52
// ! The == operator is provided so that CFileList can slowly search the list!
61
- inline bool operator ==(const struct SListEntry & other) const
53
+ inline bool operator ==(const struct SListEntry & other) const
62
54
{
63
- return fullName .string ()==other.fullName .string ();
55
+ return pathRelativeToArchive .string ()==other.pathRelativeToArchive .string ();
64
56
}
65
57
66
58
// ! The < operator is provided so that CFileList can sort and quickly search the list.
67
59
inline bool operator <(const struct SListEntry & other) const
68
60
{
69
- return fullName <other.fullName ;
61
+ return pathRelativeToArchive <other.pathRelativeToArchive ;
70
62
}
71
63
};
72
64
@@ -76,57 +68,15 @@ class IFileArchive : public core::IReferenceCounted
76
68
// List all files and directories in a specific dir of the archive
77
69
core::SRange<const SListEntry> listAssets (const path& asset_path) const ;
78
70
79
- struct SOpenFileParams
80
- {
81
- path filename;
82
- path absolutePath;
83
- std::string_view password;
84
- };
85
- #if 0
86
- core::smart_refctd_ptr<IFile> readFile(const SOpenFileParams& params)
87
- {
88
- auto index = getIndexByPath(params.filename);
89
- if (index == -1) return nullptr;
90
- switch (this->listAssets(index))
91
- {
92
- case EAT_NULL:
93
- return getFile_impl<CNullAllocator>(params, index);
94
- break;
95
- case EAT_MALLOC:
96
- return getFile_impl<CPlainHeapAllocator>(params, index);
97
- break;
98
- case EAT_VIRTUAL_ALLOC:
99
- return getFile_impl<VirtualMemoryAllocator>(params, index);
100
- break;
101
- }
102
- assert(false);
103
- return nullptr;
104
- }
105
- virtual core::smart_refctd_ptr<IFile> readFile_impl(const SOpenFileParams& params) = 0;
106
- int32_t getIndexByPath(const system::path& p)
107
- {
108
- for (int i = 0; i < m_files.size(); ++i)
109
- {
110
- if (p == m_files[i].fullName) return i;
111
- }
112
- return -1;
113
- }
114
- E_ALLOCATOR_TYPE getFileType(uint32_t index)
115
- {
116
- return m_files[index].allocatorType;
117
- }
118
-
119
- #endif
71
+ //
72
+ virtual core::smart_refctd_ptr<IFile> getFile (const path& pathRelativeToArchive, const std::string_view& password) = 0;
120
73
121
74
//
122
- IFile* asFile () { return m_file.get (); }
123
- const IFile* asFile () const { return m_file.get (); }
75
+ const path& getDefaultAbsolutePath () const {return m_defaultAbsolutePath;}
124
76
125
77
protected:
126
- IFileArchive (core::smart_refctd_ptr<IFile>&& file, system::logger_opt_smart_ptr&& logger) :
127
- m_file (std::move(file)), m_logger(std::move(logger))
128
- {
129
- }
78
+ IFileArchive (path&& _defaultAbsolutePath, system::logger_opt_smart_ptr&& logger) :
79
+ m_defaultAbsolutePath (std::move(_defaultAbsolutePath)), m_logger(std::move(logger)) {}
130
80
/*
131
81
virtual void addItem(const system::path& fullPath, uint32_t offset, uint32_t size, E_ALLOCATOR_TYPE allocatorType, uint32_t id = 0)
132
82
{
@@ -143,9 +93,16 @@ class IFileArchive : public core::IReferenceCounted
143
93
m_items.insert(std::lower_bound(m_items.begin(), m_items.end(), entry), entry);
144
94
}
145
95
*/
96
+ inline uint32_t getIndexFromPath (const system::path& pathRelativeToArchive) const
97
+ {
98
+ const IFileArchive::SListEntry itemToFind = { pathRelativeToArchive };
99
+ return std::distance (m_items.begin (),std::lower_bound (m_items.begin (),m_items.end (),itemToFind));
100
+ }
101
+
102
+ path m_defaultAbsolutePath;
146
103
// files and directories
147
104
core::vector<SListEntry> m_items;
148
- core::smart_refctd_ptr<IFile> m_file;
105
+ //
149
106
system::logger_opt_smart_ptr m_logger;
150
107
};
151
108
0 commit comments