Skip to content

Commit

Permalink
Fix legacy config loading
Browse files Browse the repository at this point in the history
  • Loading branch information
J-D-K committed Aug 31, 2021
1 parent fe5656b commit a2bf9a8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ INCLUDES := inc inc/ui
EXEFS_SRC := exefs_src
APP_TITLE := JKSV
APP_AUTHOR := JK
APP_VERSION := 08.19.2021
APP_VERSION := 08.31.2021
ROMFS := romfs
ICON := icon.jpg

Expand Down
2 changes: 1 addition & 1 deletion inc/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "gfx.h"

#define BLD_MON 8
#define BLD_DAY 24
#define BLD_DAY 31
#define BLD_YEAR 2021

namespace data
Expand Down
22 changes: 12 additions & 10 deletions src/cfg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ static void loadWorkDirLegacy()
memset(tmp, 0, 256);

FILE *getDir = fopen(workDirLegacy, "r");
fgets(tmp, FS_MAX_PATH, getDir);
fgets(tmp, 256, getDir);
fclose(getDir);
std::string tmpStr = tmp;
util::stripChar('\n', tmpStr);
Expand Down Expand Up @@ -227,13 +227,13 @@ static void loadConfigLegacy()
cfg::config["zip"] = cfgIn >> 51 & 1;
cfg::config["langOverride"] = cfgIn >> 50 & 1;
cfg::config["trashBin"] = cfgIn >> 49 & 1;
fs::delfile(cfgPath);
fs::delfile(legacyCfgPath.c_str());
}
}

static void loadFavoritesLegacy()
{
std::string legacyFavPath = fs::getWorkDir() + "cfg::favorites.txt";
std::string legacyFavPath = fs::getWorkDir() + "favorites.txt";
if(fs::fileExists(legacyFavPath))
{
fs::dataFile fav(legacyFavPath);
Expand All @@ -246,7 +246,7 @@ static void loadFavoritesLegacy()

static void loadBlacklistLegacy()
{
std::string legacyBlPath = fs::getWorkDir() + "cfg::blacklist.txt";
std::string legacyBlPath = fs::getWorkDir() + "blacklist.txt";
if(fs::fileExists(legacyBlPath))
{
fs::dataFile bl(legacyBlPath);
Expand All @@ -257,20 +257,19 @@ static void loadBlacklistLegacy()
}
}

static void loadTitleDefs()
static void loadTitleDefsLegacy()
{
std::string titleDefLegacy = fs::getWorkDir() + "titleDefs.txt";
if(fs::fileExists(titleDefLegacy))
rename(titleDefLegacy.c_str(), titleDefPath);

if(fs::fileExists(titleDefPath))
{
fs::dataFile getPaths(titleDefPath);
fs::dataFile getPaths(titleDefLegacy);
while(getPaths.readNextLine(true))
{
uint64_t tid = strtoul(getPaths.getName().c_str(), NULL, 16);
pathDefs[tid] = getPaths.getNextValueStr();
}
getPaths.close();
fs::delfile(titleDefLegacy);
}
}

Expand All @@ -280,6 +279,7 @@ void cfg::loadConfig()
loadConfigLegacy();
loadFavoritesLegacy();
loadBlacklistLegacy();
loadTitleDefsLegacy();

if(fs::fileExists(cfgPath))
{
Expand Down Expand Up @@ -380,10 +380,12 @@ void cfg::loadConfig()
case 18:
cfg::config["autoName"] = textToBool(cfgRead.getNextValueStr());
break;

default:
break;
}
}
}
loadTitleDefs();
}

static void savePathDefs()
Expand Down
7 changes: 5 additions & 2 deletions src/fsthrd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,11 @@ void fs::createSaveData_t(void *a)

FsSaveDataMetaInfo meta;
memset(&meta, 0, sizeof(FsSaveDataMetaInfo));
meta.size = 0x40060;
meta.type = FsSaveDataMetaType_Thumbnail;
if(s->type != FsSaveDataType_Bcat)
{
meta.size = 0x40060;
meta.type = FsSaveDataMetaType_Thumbnail;
}

Result res = 0;
if(R_SUCCEEDED(res = fsCreateSaveDataFileSystem(&attr, &svCreate, &meta)))
Expand Down

0 comments on commit a2bf9a8

Please sign in to comment.