MCPcopy Create free account
hub / github.com/codereader/DarkRadiant / traverse

Method traverse

radiantcore/vfs/GenericFileSystem.h:167–191  ·  view source on GitHub ↗

\brief Performs a depth-first traversal of the file-system subtree rooted at \p root. Traverses the entire tree if \p root is "". Calls \p visitor.file() with the path to each file relative to the filesystem root. Calls \p visitor.directory() with the path to each directory relative to the filesystem root.

Source from the content-addressed store, hash-verified

165 /// Calls \p visitor.file() with the path to each file relative to the filesystem root.
166 /// Calls \p visitor.directory() with the path to each directory relative to the filesystem root.
167 void traverse(IArchive::Visitor& visitor, const std::string& root, IArchiveFileInfoProvider& infoProvider)
168 {
169 unsigned int start_depth = getPathDepth(root.c_str());
170 unsigned int skip_depth = 0;
171
172 for (iterator i = begin(root); i != end() && i->first.depth() > start_depth; ++i)
173 {
174 if (i->first.depth() == skip_depth)
175 {
176 skip_depth = 0;
177 }
178
179 if (skip_depth == 0)
180 {
181 if (!i->second.isDirectory())
182 {
183 visitor.visitFile(i->first.string(), infoProvider);
184 }
185 else if (visitor.visitDirectory(i->first.string(), i->first.depth() - start_depth))
186 {
187 skip_depth = i->first.depth();
188 }
189 }
190 }
191 }
192
193private:
194 iterator begin(const std::string& root)

Callers

nothing calls this directly

Calls 9

getPathDepthFunction · 0.85
beginFunction · 0.85
endFunction · 0.85
isDirectoryMethod · 0.80
stringMethod · 0.80
visitDirectoryMethod · 0.80
c_strMethod · 0.45
depthMethod · 0.45
visitFileMethod · 0.45

Tested by

no test coverage detected