diff --git a/doomsday/sdk/libcore/include/de/filesys/fileindex.h b/doomsday/sdk/libcore/include/de/filesys/fileindex.h index a32e7b15ac..e1af013488 100644 --- a/doomsday/sdk/libcore/include/de/filesys/fileindex.h +++ b/doomsday/sdk/libcore/include/de/filesys/fileindex.h @@ -141,7 +141,10 @@ class DENG2_PUBLIC FileIndex void print() const; - // C++ iterator: + QList files() const; + +protected: + // C++ iterator (not thread safe): typedef Index::const_iterator const_iterator; Index::const_iterator begin() const; Index::const_iterator end() const; diff --git a/doomsday/sdk/libcore/src/filesys/file.cpp b/doomsday/sdk/libcore/src/filesys/file.cpp index 8c7d54b812..3f92adba06 100644 --- a/doomsday/sdk/libcore/src/filesys/file.cpp +++ b/doomsday/sdk/libcore/src/filesys/file.cpp @@ -341,6 +341,7 @@ File *File::reinterpret() if (folder) { folder->remove(*this); + deindex(); } original->flush(); @@ -357,6 +358,7 @@ File *File::reinterpret() if (folder) { folder->add(result); + fileSystem().index(*result); } return result; } diff --git a/doomsday/sdk/libcore/src/filesys/fileindex.cpp b/doomsday/sdk/libcore/src/filesys/fileindex.cpp index 63fd5b08b2..704d4d36cd 100644 --- a/doomsday/sdk/libcore/src/filesys/fileindex.cpp +++ b/doomsday/sdk/libcore/src/filesys/fileindex.cpp @@ -217,4 +217,16 @@ void FileIndex::print() const } } +QList FileIndex::files() const +{ + DENG2_GUARD_READ(d); + + QList list; + for (auto i = begin(); i != end(); ++i) + { + list.append(i->second); + } + return list; +} + } // namespace de diff --git a/doomsday/sdk/libcore/src/filesys/filesystem.cpp b/doomsday/sdk/libcore/src/filesys/filesystem.cpp index 4e2376a645..cd5bc381f4 100644 --- a/doomsday/sdk/libcore/src/filesys/filesystem.cpp +++ b/doomsday/sdk/libcore/src/filesys/filesystem.cpp @@ -258,6 +258,8 @@ void FileSystem::index(File &file) { d->index.maybeAdd(file); + //qDebug() << "[FS] Indexing" << file.path() << DENG2_TYPE_NAME(file); + // Also make an entry in the type index. d->getTypeIndex(DENG2_TYPE_NAME(file)).maybeAdd(file); @@ -293,6 +295,7 @@ File &FileSystem::copySerialized(String const &sourcePath, String const &destina if (behavior & ReinterpretDestination) { // We can now reinterpret and populate the contents of the archive. + //qDebug() << "[FS] Reinterpreting" << dest->path(); dest = dest->reinterpret(); } diff --git a/doomsday/sdk/libcore/src/filesys/packageloader.cpp b/doomsday/sdk/libcore/src/filesys/packageloader.cpp index 0416e279e3..bfecfc8634 100644 --- a/doomsday/sdk/libcore/src/filesys/packageloader.cpp +++ b/doomsday/sdk/libcore/src/filesys/packageloader.cpp @@ -241,45 +241,46 @@ DENG2_PIMPL(PackageLoader) void listPackagesInIndex(FileIndex const &index, StringList &list) { - for (auto i = index.begin(); i != index.end(); ++i) + foreach (File *indexedFile, index.files()) { - if (shouldIgnoreFile(*i->second)) continue; + if (shouldIgnoreFile(*indexedFile)) continue; - if (i->first.fileNameExtension() == ".pack") + String const fileName = indexedFile->name(); + if (fileName.fileNameExtension() == ".pack") { try { - File &file = *i->second; - String path = file.path(); + //File &file = *indexedFile; + String path = indexedFile->path(); // The special persistent data package should be ignored. - if (path == "/home/persist.pack") continue; + if (path == QStringLiteral("/home/persist.pack")) continue; // Check the metadata. - checkPackage(file); + checkPackage(*indexedFile); list.append(path); } catch (Package::NotPackageError const &er) { // This is usually a .pack folder used only for nesting. - LOG_RES_XVERBOSE("\"%s\": %s") << i->first << er.asText(); + LOG_RES_XVERBOSE("\"%s\": %s") << fileName << er.asText(); } catch (Package::ValidationError const &er) { // Not a loadable package. - LOG_RES_MSG("\"%s\": Package is invalid: %s") << i->first << er.asText(); + LOG_RES_MSG("\"%s\": Package is invalid: %s") << fileName << er.asText(); } catch (Parser::SyntaxError const &er) { LOG_RES_WARNING("\"%s\": Package has a Doomsday Script syntax error: %s") - << i->first << er.asText(); + << fileName << er.asText(); } catch (Info::SyntaxError const &er) { // Not a loadable package. LOG_RES_WARNING("\"%s\": Package has a syntax error: %s") - << i->first << er.asText(); + << fileName << er.asText(); } /// @todo Store the errors so that the UI can show a list of