| 121 | } |
| 122 | |
| 123 | void collectFiles(FS_Archive arch, const std::u16string& root, const std::u16string& sub, std::vector<SendFile>& out, |
| 124 | std::vector<std::string>* outDirs = nullptr) |
| 125 | { |
| 126 | std::u16string current = root; |
| 127 | if (!current.empty() && current.back() != u'/') { |
| 128 | current += StringUtils::UTF8toUTF16("/"); |
| 129 | } |
| 130 | current += sub; |
| 131 | Directory items(arch, current); |
| 132 | if (!items.good()) { |
| 133 | return; |
| 134 | } |
| 135 | for (size_t i = 0, sz = items.size(); i < sz; i++) { |
| 136 | std::u16string name = items.entry(i); |
| 137 | if (name == u"." || name == u"..") { |
| 138 | continue; |
| 139 | } |
| 140 | if (items.folder(i)) { |
| 141 | std::u16string nextSub = sub + name + StringUtils::UTF8toUTF16("/"); |
| 142 | if (outDirs != nullptr) { |
| 143 | outDirs->push_back(StringUtils::UTF16toUTF8(nextSub)); |
| 144 | } |
| 145 | collectFiles(arch, root, nextSub, out, outDirs); |
| 146 | } |
| 147 | else { |
| 148 | std::u16string abs = current + name; |
| 149 | std::string rel = StringUtils::UTF16toUTF8(sub + name); |
| 150 | FSStream input(arch, abs, FS_OPEN_READ); |
| 151 | if (!input.good()) { |
| 152 | continue; |
| 153 | } |
| 154 | SendFile entry; |
| 155 | entry.absPath = StringUtils::UTF16toUTF8(abs); |
| 156 | entry.relPath = rel; |
| 157 | entry.size = input.size(); |
| 158 | input.close(); |
| 159 | out.push_back(entry); |
| 160 | } |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | bool ensureDirectoryPath(const std::u16string& base, const std::string& relPath) |
| 165 | { |