Skip to content

Commit

Permalink
Refactor: Use improved FS2 flushing, file system utils
Browse files Browse the repository at this point in the history
It is no longer necessary or advisable to change a file to ReadOnly
mode after writing it. Instead, the file should just be flushed.
  • Loading branch information
skyjake committed Apr 5, 2014
1 parent 9c1d00d commit 9cc96cf
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions doomsday/client/src/resource/resourcesystem.cpp
Expand Up @@ -1971,10 +1971,10 @@ DENG2_PIMPL(ResourceSystem)

if(namePattern.isValid() && !namePattern.isEmpty())
{
Folder &sourceFolder = App::fileSystem().makeFolder(de::String("/legacySavegames") / gameId, FS::DontInheritFeeds);
sourceFolder.attach(new DirectoryFeed(oldSavePath));
sourceFolder.populate(Folder::PopulateOnlyThisFolder);
sourceFolder.setMode(Folder::ReadOnly);
Folder &sourceFolder = App::fileSystem().makeFolderWithFeed(
de::String("/legacySavegames") / gameId,
new DirectoryFeed(oldSavePath),
Folder::PopulateOnlyThisFolder /* no need to go deep */);

//ArrayValue *pathList = 0;
DENG2_FOR_EACH_CONST(Folder::Contents, i, sourceFolder.contents())
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/settingsregister.cpp
Expand Up @@ -521,7 +521,7 @@ DENG2_OBSERVES(App, GameChange)
// Create the pack and update the file system.
File &outFile = App::rootFolder().replaceFile(fileName());
outFile << info.toUtf8();
outFile.setMode(File::ReadOnly); // we're done
outFile.flush(); // we're done

LOG_VERBOSE("Wrote \"%s\" with %i profile%s") << fileName() << count << (count != 1? "s" : "");
}
Expand Down
4 changes: 2 additions & 2 deletions doomsday/libdeng2/include/de/game/savedsession.h
Expand Up @@ -31,8 +31,8 @@ namespace game {
/**
* Specialized PackageFolder that hosts a serialized game session.
*
* Expands upon the services provided by the base class, adding various convenience methods
* for inspecting the data within.
* Expands upon the services provided by the base class, adding various
* convenience methods for inspecting the data within.
*
* @ingroup game
*/
Expand Down
2 changes: 1 addition & 1 deletion doomsday/tools/savegametool/src/id1translator.cpp
Expand Up @@ -271,6 +271,6 @@ void Id1Translator::convert(Path path)

File &outFile = outputFolder().replaceFile(saveName.fileNameWithoutExtension() + ".save");
Writer(outFile) << arch;
outFile.setMode(File::ReadOnly);
outFile.flush();
LOG_MSG("Wrote ") << outFile.as<NativeFile>().nativePath().pretty();
}
4 changes: 2 additions & 2 deletions doomsday/tools/savegametool/src/nativetranslator.cpp
Expand Up @@ -703,6 +703,6 @@ void NativeTranslator::convert(Path path)

File &outFile = outputFolder().replaceFile(saveName.fileNameWithoutExtension() + ".save");
Writer(outFile) << arch;
outFile.setMode(File::ReadOnly);
LOG_MSG("Wrote ") << outFile.as<NativeFile>().nativePath().pretty();
outFile.flush();
LOG_MSG("Wrote %s") << outFile.description();
}

0 comments on commit 9cc96cf

Please sign in to comment.