예제 #1
0
 void locateLegacySavegames(String const &gameId)
 {
     LOG_AS("SaveGames");
     String const legacySavePath = String("/sys/legacysavegames") / gameId;
     if (Folder *oldSaveFolder = FileSystem::get().root().tryLocate<Folder>(legacySavePath))
     {
         // Add any new legacy savegames which may have appeared in this folder.
         oldSaveFolder->populate(Folder::PopulateOnlyThisFolder /* no need to go deep */);
     }
     else
     {
         try
         {
             // Make and setup a feed for the /sys/legacysavegames/<gameId> subfolder if the game
             // might have legacy savegames we may need to convert later.
             NativePath const oldSavePath = DoomsdayApp::games()[gameId].legacySavegamePath();
             if (oldSavePath.exists() && oldSavePath.isReadable())
             {
                 FileSystem::get().makeFolderWithFeed(legacySavePath,
                         new DirectoryFeed(oldSavePath),
                         Folder::PopulateOnlyThisFolder /* no need to go deep */);
             }
         }
         catch (Games::NotFoundError const &)
         {} // Ignore this error
     }
 }
예제 #2
0
int SavegameConvertHook(int /*hook_type*/, int /*parm*/, void *data)
{
    DENG2_ASSERT(data != 0);
    ddhook_savegame_convert_t const &parm = *static_cast<ddhook_savegame_convert_t *>(data);

    LOG_AS("importsave");

    // First locate the savegametool executable.
    NativePath bin = findSavegameTool();
    if(!bin.exists())
    {
        LOG_RES_ERROR("Failed to locate Savegame Tool");
        return false;
    }
    CommandLine cmd;
    cmd << bin;

    // Specify the fallback game identity key for ambiguous format resolution.
    cmd << "-idkey" << Str_Text(&parm.fallbackGameId);

    // We can only convert native files and output to native folders using Savegame Tool.
    Path const outputPath(Str_Text(&parm.outputPath));
    Path const sourcePath(Str_Text(&parm.sourcePath));
    try
    {
        // Redirect output to the folder specified.
        cmd << "-output" << App::rootFolder().locate<Folder>(outputPath)
                                                .feeds().front()->as<DirectoryFeed>().nativePath().expand();

        // Add the path of the savegame to be converted.
        cmd << App::rootFolder().locate<NativeFile>(sourcePath).nativePath();

        LOG_RES_NOTE("Starting conversion of \"%s\" using Savegame Tool") << sourcePath;
        cmd.executeAndWait();
        return true;
    }
    catch(Error const &er)
    {
        LOG_RES_NOTE("Failed conversion of \"%s\":\n") << sourcePath << er.asText();
    }

    return false;
}