| 106 | InputStream MPQ::load(const std::string_view fileName) { return InputStream(std::make_unique<MPQStream>(_stormMpq, fixPath(fileName))); } |
| 107 | |
| 108 | std::vector<std::string> MPQ::fileList() { |
| 109 | std::vector<std::string> result; |
| 110 | |
| 111 | if (!has("(listfile)")) { |
| 112 | Common::Log::error("MPQ does not contain a listfile."); |
| 113 | } |
| 114 | |
| 115 | auto stream = load("(listfile)"); |
| 116 | |
| 117 | std::string line; |
| 118 | while (true) { |
| 119 | std::getline(stream, line); |
| 120 | if (stream.eof()) { |
| 121 | break; |
| 122 | } |
| 123 | |
| 124 | // Remove the \r character from the line |
| 125 | line.erase(std::remove(line.begin(), line.end(), '\r'), line.end()); |
| 126 | |
| 127 | result.push_back(line); |
| 128 | } |
| 129 | |
| 130 | return result; |
| 131 | } |
| 132 | |
| 133 | } // namespace Abyss::FileSystem |