| 47 | { |
| 48 | |
| 49 | void 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 |
nothing calls this directly
no test coverage detected