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

Method initDirectory

radiantcore/vfs/Doom3FileSystem.cpp:49–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47{
48
49void Doom3FileSystem::initDirectory(const std::string& inputPath)
50{
51 // greebo: Normalise path: Replace backslashes and ensure trailing slash
52 _directories.push_back(os::standardPathWithSlash(inputPath));
53
54 // Shortcut
55 const std::string& path = _directories.back();
56
57 {
58 ArchiveDescriptor entry;
59 entry.name = path;
60 entry.archive = std::make_shared<DirectoryArchive>(path);
61 entry.is_pakfile = false;
62
63 _archives.push_back(entry);
64 }
65
66 // Instantiate a new sorting container for the filenames
67 SortedFilenames filenameList;
68
69 // Traverse the directory using the filename list as functor
70 try
71 {
72 os::forEachItemInDirectory(path, [&](const fs::path& file)
73 {
74 try
75 {
76 // Just insert the name, it will get sorted correctly.
77 filenameList.insert(file.filename().string());
78 }
79 catch (std::system_error& ex)
80 {
81 rWarning() << "[vfs] Skipping file " << string::unicode_to_utf8(file.filename().wstring()) <<
82 " - possibly unsupported characters in filename? " <<
83 "(Exception: " << ex.what() << ")" << std::endl;
84 }
85 });
86 }
87 catch (os::DirectoryNotFoundException&)
88 {
89 rError() << "[vfs] Directory '" << path << "' not found." << std::endl;
90 }
91
92 if (filenameList.empty())
93 {
94 return; // nothing found
95 }
96
97 rMessage() << "[vfs] Searched directory: " << path << std::endl;
98
99 // add the entries to the vfs
100 for (const std::string& filename : filenameList)
101 {
102 // Assemble the filename and try to load the archive
103 initPakFile(path + filename);
104 }
105}
106

Callers

nothing calls this directly

Calls 12

forEachItemInDirectoryFunction · 0.85
rWarningFunction · 0.85
unicode_to_utf8Function · 0.85
rErrorFunction · 0.85
rMessageFunction · 0.85
backMethod · 0.80
stringMethod · 0.80
whatMethod · 0.80
standardPathWithSlashFunction · 0.50
push_backMethod · 0.45
insertMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected