| 236 | } |
| 237 | |
| 238 | void DirectoryRefresher::stealModFilesIntoStructure(DirectoryEntry* directoryStructure, |
| 239 | const QString& modName, |
| 240 | int priority, |
| 241 | const QString& directory, |
| 242 | const QStringList& stealFiles) |
| 243 | { |
| 244 | std::wstring directoryW = ToWString(QDir::toNativeSeparators(directory)); |
| 245 | |
| 246 | // instead of adding all the files of the target directory, we just change the root of |
| 247 | // the specified files to this mod |
| 248 | DirectoryStats dummy; |
| 249 | FilesOrigin& origin = |
| 250 | directoryStructure->createOrigin(ToWString(modName), directoryW, priority, dummy); |
| 251 | |
| 252 | for (const QString& filename : stealFiles) { |
| 253 | if (filename.isEmpty()) { |
| 254 | log::warn("Trying to find file with no name"); |
| 255 | log::warn(" . modName: {}", modName); |
| 256 | log::warn(" . directory: {}", directory); |
| 257 | log::warn(" . priority: {}", priority); |
| 258 | for (int i = 0; i < stealFiles.length(); ++i) |
| 259 | log::warn(" . stealFiles[{}]: {}", i, stealFiles[i]); |
| 260 | continue; |
| 261 | } |
| 262 | QFileInfo fileInfo(filename); |
| 263 | FileEntryPtr file = directoryStructure->findFile(ToWString(fileInfo.fileName())); |
| 264 | if (file.get() != nullptr) { |
| 265 | if (file->getOrigin() == 0) { |
| 266 | // replace data as the origin on this bsa |
| 267 | file->removeOrigin(0); |
| 268 | } |
| 269 | origin.addFile(file->getIndex()); |
| 270 | file->addOrigin(origin.getID(), file->getFileTime(), L"", -1); |
| 271 | } else { |
| 272 | QString warnStr = fileInfo.absolutePath(); |
| 273 | if (warnStr.isEmpty()) |
| 274 | warnStr = filename; |
| 275 | log::warn("file not found: {}", warnStr); |
| 276 | } |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | void DirectoryRefresher::addModFilesToStructure(DirectoryEntry* directoryStructure, |
| 281 | const QString& modName, int priority, |
nothing calls this directly
no test coverage detected