mirror of
https://github.com/J-D-K/JKSV.git
synced 2026-08-28 13:34:05 -05:00
Fix up some stuff, use va_list for log
This commit is contained in:
2
Makefile
2
Makefile
@@ -38,7 +38,7 @@ INCLUDES := inc
|
||||
EXEFS_SRC := exefs_src
|
||||
APP_TITLE := JKSV
|
||||
APP_AUTHOR := JK
|
||||
APP_VERSION := 04.06.2020
|
||||
APP_VERSION := 04.10.2020
|
||||
ROMFS := romfs
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace data
|
||||
{
|
||||
public:
|
||||
//Attempts to read title's info
|
||||
void init(const FsSaveDataInfo& inf);
|
||||
void init(const FsSaveDataInfo& inf, NsApplicationControlData *dat);
|
||||
|
||||
//Attempts to mount data with uID + id. Returns false if fails. For filtering.
|
||||
bool isMountable(const AccountUid& uID);
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace fs
|
||||
};
|
||||
|
||||
void logOpen();
|
||||
void logWrite(const std::string& out);
|
||||
void logWrite(const char *fmt, ...);
|
||||
void logClose();
|
||||
}
|
||||
|
||||
|
||||
21
src/data.cpp
21
src/data.cpp
@@ -171,6 +171,8 @@ namespace data
|
||||
users.push_back(sys);
|
||||
//users.push_back(sysBcat);
|
||||
|
||||
//Stop allocing and freeing over and over for every title.
|
||||
NsApplicationControlData *dat = new NsApplicationControlData;
|
||||
while(R_SUCCEEDED(fsSaveDataInfoReaderRead(&saveIt, &info, 1, &total)) && total != 0)
|
||||
{
|
||||
switch(info.save_data_type)
|
||||
@@ -206,7 +208,7 @@ namespace data
|
||||
|
||||
u = getUserIndex(info.uid);
|
||||
titledata newData;
|
||||
newData.init(info);
|
||||
newData.init(info, dat);
|
||||
if(isFavorite(newData.getID()))
|
||||
newData.setFav(true);
|
||||
|
||||
@@ -217,7 +219,7 @@ namespace data
|
||||
else
|
||||
{
|
||||
titledata newData;
|
||||
newData.init(info);
|
||||
newData.init(info, dat);
|
||||
if(isFavorite(newData.getID()))
|
||||
newData.setFav(true);
|
||||
|
||||
@@ -226,6 +228,7 @@ namespace data
|
||||
}
|
||||
}
|
||||
}
|
||||
delete dat;
|
||||
fsSaveDataInfoReaderClose(&saveIt);
|
||||
|
||||
if(data::incDev)
|
||||
@@ -296,10 +299,9 @@ namespace data
|
||||
drawText("♥", iconFav, ui::shared, 0, 0, 48, clrCreateU32(0xFF4444FF));
|
||||
}
|
||||
|
||||
void titledata::init(const FsSaveDataInfo& inf)
|
||||
void titledata::init(const FsSaveDataInfo& inf, NsApplicationControlData *dat)
|
||||
{
|
||||
size_t outSz = 0;
|
||||
NsApplicationControlData *dat = new NsApplicationControlData;
|
||||
NacpLanguageEntry *ent = NULL;
|
||||
memset(dat, 0, sizeof(NsApplicationControlData));
|
||||
|
||||
@@ -311,7 +313,8 @@ namespace data
|
||||
saveDataType = inf.save_data_type;
|
||||
Result ctrlDataRes = nsGetApplicationControlData(NsApplicationControlSource_Storage, id, dat, sizeof(NsApplicationControlData), &outSz);
|
||||
Result nacpRes = nacpGetLanguageEntry(&dat->nacp, &ent);
|
||||
if(R_SUCCEEDED(ctrlDataRes) && !(outSz < sizeof(dat->nacp)) && R_SUCCEEDED(nacpRes) && ent != NULL)
|
||||
size_t icnSize = outSz - sizeof(dat->nacp);
|
||||
if(R_SUCCEEDED(ctrlDataRes) && !(outSz < sizeof(dat->nacp)) && R_SUCCEEDED(nacpRes) && ent != NULL && icnSize > 0)
|
||||
{
|
||||
title.assign(ent->name);
|
||||
titleSafe.assign(util::safeString(title));
|
||||
@@ -326,13 +329,13 @@ namespace data
|
||||
int icnInd = findIcnIndex(id);
|
||||
if(icnInd == -1)
|
||||
{
|
||||
size_t icnSize = outSz - sizeof(dat->nacp);
|
||||
icn newIcn;
|
||||
newIcn.load(id, dat->icon, icnSize);
|
||||
newIcn.createFav();
|
||||
icons.push_back(newIcn);
|
||||
|
||||
icon = icons[findIcnIndex(id)];
|
||||
//safe to assume icon is last
|
||||
icon = data::icons[data::icons.size() - 1];
|
||||
}
|
||||
else
|
||||
icon = icons[icnInd];
|
||||
@@ -351,8 +354,6 @@ namespace data
|
||||
}
|
||||
|
||||
path = fs::getWorkDir() + titleSafe + "/";
|
||||
|
||||
delete dat;
|
||||
}
|
||||
|
||||
bool titledata::isMountable(const AccountUid& uID)
|
||||
@@ -394,7 +395,7 @@ namespace data
|
||||
if(userSafe.empty())
|
||||
{
|
||||
char tmp[32];
|
||||
sprintf(tmp, "Acc%016lX", (uint64_t)uID128);
|
||||
sprintf(tmp, "Acc%08X", (uint32_t)uID128);
|
||||
userSafe = tmp;
|
||||
}
|
||||
|
||||
|
||||
15
src/file.cpp
15
src/file.cpp
@@ -4,6 +4,7 @@
|
||||
#include <switch.h>
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <cstdarg>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "file.h"
|
||||
@@ -467,15 +468,21 @@ namespace fs
|
||||
fsFsOpenFile(sd, "/JKSV/log.txt", FsOpenMode_Write, &logFile);
|
||||
}
|
||||
|
||||
void logWrite(const std::string& out)
|
||||
void logWrite(const char *fmt, ...)
|
||||
{
|
||||
char tmp[256];
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
vsprintf(tmp, fmt, args);
|
||||
|
||||
unsigned tmpLength = strlen(tmp);
|
||||
s64 curSize = 0;
|
||||
fsFileGetSize(&logFile, &curSize);
|
||||
curSize += out.size();
|
||||
curSize += tmpLength;
|
||||
fsFileSetSize(&logFile, curSize);
|
||||
|
||||
fsFileWrite(&logFile, offset, out.c_str(), out.length(), 0);
|
||||
offset += out.length();
|
||||
fsFileWrite(&logFile, offset, tmp, tmpLength, 0);
|
||||
offset += tmpLength;
|
||||
}
|
||||
|
||||
void logClose()
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "util.h"
|
||||
#include "file.h"
|
||||
|
||||
#define VER_STRING "v. 04.06.2020"
|
||||
#define VER_STRING "v. 04.10.2020"
|
||||
|
||||
//Nav buttons
|
||||
std::vector<ui::button> usrNav, ttlNav, fldNav;
|
||||
|
||||
Reference in New Issue
Block a user