MCPcopy Create free account
hub / github.com/ModOrganizer2/modorganizer / stealModFilesIntoStructure

Method stealModFilesIntoStructure

src/directoryrefresher.cpp:238–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

236}
237
238void 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
280void DirectoryRefresher::addModFilesToStructure(DirectoryEntry* directoryStructure,
281 const QString& modName, int priority,

Callers

nothing calls this directly

Calls 12

ToWStringFunction · 0.85
addOriginMethod · 0.80
getIDMethod · 0.80
isEmptyMethod · 0.45
findFileMethod · 0.45
getMethod · 0.45
getOriginMethod · 0.45
removeOriginMethod · 0.45
addFileMethod · 0.45
getIndexMethod · 0.45
getFileTimeMethod · 0.45
absolutePathMethod · 0.45

Tested by

no test coverage detected