MCPcopy Create free account
hub / github.com/crownengine/crown / scan_directory

Method scan_directory

src/resource/data_compiler.cpp:133–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

131}
132
133void SourceIndex::scan_directory(FilesystemDisk &fs, const char *prefix, const char *directory)
134{
135 Vector<DynamicString> files(default_allocator());
136 fs.list_files(directory != NULL ? directory : "", files);
137
138 for (u32 i = 0; i < vector::size(files); ++i) {
139 TempAllocator512 ta;
140 DynamicString file_i(ta);
141
142 if (directory != NULL) {
143 file_i += directory;
144 file_i += '/';
145 }
146 file_i += files[i];
147
148 if (fs.is_directory(file_i.c_str())) {
149 DynamicString directory_name(ta);
150 if (strcmp(prefix, "") != 0) {
151 directory_name += prefix;
152 directory_name += '/';
153 }
154 directory_name += file_i;
155 notify_add_tree(directory_name.c_str());
156
157 scan_directory(fs, prefix, file_i.c_str());
158 } else { // Assume a regular file
159 DynamicString resource_name(ta);
160 if (strcmp(prefix, "") != 0) {
161 resource_name += prefix;
162 resource_name += '/';
163 }
164 resource_name += file_i;
165
166 Stat st;
167 st = fs.stat(file_i.c_str());
168 hash_map::set(_paths, resource_name, st);
169
170 notify_add_file(resource_name.c_str(), st);
171 }
172 }
173}
174
175void SourceIndex::scan(const HashMap<DynamicString, DynamicString> &source_dirs)
176{

Callers

nothing calls this directly

Calls 9

strcmpFunction · 0.85
notify_add_treeFunction · 0.85
setClass · 0.85
notify_add_fileFunction · 0.85
sizeFunction · 0.50
list_filesMethod · 0.45
is_directoryMethod · 0.45
c_strMethod · 0.45
statMethod · 0.45

Tested by

no test coverage detected