Make 'Dump All' available to user

This commit is contained in:
J-D-K 2018-06-22 22:23:58 -04:00
parent 22158a72eb
commit 35dc485896
10 changed files with 85 additions and 47 deletions

View File

@ -38,7 +38,7 @@ INCLUDES := inc
EXEFS_SRC := exefs_src
APP_TITLE := JKSV
APP_AUTHOR := JK_
APP_VERSION := 06/20/2018
APP_VERSION := 06/22/2018
ROMFS := romfs
#---------------------------------------------------------------------------------

View File

@ -25,6 +25,9 @@ namespace fs
//Recursively deletes 'path'
void delDir(const std::string& path);
//Dumps all titles for 'user'
void dumpAllUserSaves(data::user& u);
//Just retrieves a listing for _path and stores it in item vector
class dirList
{

View File

@ -8,8 +8,7 @@ namespace sys
bool fini();
//Uh oh
extern bool sysSave;
extern bool devMenu;
extern bool sysSave, devMenu, forceMountable;
}
#endif // SYS_H

View File

@ -24,5 +24,7 @@ namespace util
//Removes last folder from '_path'
void removeLastFolderFromString(std::string& _path);
std::string safeString(const std::string& s);
}
#endif // UTIL_H

View File

@ -9,35 +9,7 @@
#include "data.h"
#include "sys.h"
#include "file.h"
static const char verboten[] = { '.', ',', '/', '\\', '<', '>', ':', '"', '|', '?', '*'};
bool isVerboten(char t)
{
for(unsigned i = 0; i < 11; i++)
{
if(t == verboten[i])
return true;
}
return false;
}
std::string safeString(const std::string& s)
{
std::string ret = "";
for(unsigned i = 0; i < s.length(); i++)
{
if(isVerboten(s[i]))
{
ret += ' ';
}
else
ret += s[i];
}
return ret;
}
#include "util.h"
namespace data
{
@ -125,14 +97,14 @@ namespace data
u = getUserIndex(info.userID);
titledata newData;
if(newData.init(info) && newData.isMountable(newUser.getUID()))
if(newData.init(info) && (!sys::forceMountable || newData.isMountable(newUser.getUID())))
users[u].titles.push_back(newData);
}
}
else
{
titledata newData;
if(newData.init(info) && newData.isMountable(users[u].getUID()))
if(newData.init(info) && (!sys::forceMountable || newData.isMountable(users[u].getUID())))
{
users[u].titles.push_back(newData);
}
@ -184,7 +156,7 @@ namespace data
if(R_SUCCEEDED(res))
{
title.assign(ent->name);
titleSafe = safeString(ent->name);
titleSafe = util::safeString(ent->name);
delete dat;
}
else
@ -192,7 +164,7 @@ namespace data
char tmp[32];
sprintf(tmp, "%016lX", (u64)id);
title.assign(tmp);
titleSafe = safeString(tmp);
titleSafe = util::safeString(tmp);
}
return true;
@ -249,7 +221,7 @@ namespace data
username.assign(base.username);
if(username.empty())
username = "Unknown";
userSafe = safeString(username);
userSafe = util::safeString(username);
accountProfileClose(&prof);
@ -273,7 +245,7 @@ namespace data
if(R_SUCCEEDED(res))
{
username.assign(base.username);
userSafe = safeString(username);
userSafe = util::safeString(username);
accountProfileClose(&prof);
}
else

View File

@ -249,4 +249,26 @@ namespace fs
rmdir(path.c_str());
}
void dumpAllUserSaves(data::user& u)
{
for(unsigned i = 0; i < u.titles.size(); i++)
{
if(fs::mountSave(u, u.titles[i]))
{
util::makeTitleDir(u, u.titles[i]);
//sdmc:/JKSV/[title]/[user] - [date]/
std::string outPath = util::getTitleDir(u, u.titles[i]) + u.getUsernameSafe() + " - " + util::getDateTime();
mkdir(outPath.c_str(), 777);
outPath += "/";
std::string root = "sv:/";
fs::copyDirToDir(root, outPath);
fsdevUnmountDevice("sv");
}
}
}
}

View File

@ -262,7 +262,7 @@ namespace gfx
dataIn.read((char *)&width, sizeof(uint16_t));
dataIn.read((char *)&height, sizeof(uint16_t));
data = new uint32_t[sz];
data = new uint32_t[sz / sizeof(uint32_t)];
if(data != NULL)
dataIn.read((char *)data, sz);

View File

@ -9,6 +9,7 @@ namespace sys
{
bool sysSave = false;
bool devMenu = false;
bool forceMountable = true;
void loadCfg()
{
@ -21,9 +22,10 @@ namespace sys
sysSave = byte >> 7 & 1;
devMenu = byte >> 6 & 1;
forceMountable = byte >> 5 & 1;
//Make sure the rest are 0
for(int i = 5; i > -1; i--)
for(int i = 4; i > -1; i--)
{
bool chk = byte >> i & 1;
if(chk == true)

View File

@ -535,7 +535,7 @@ namespace ui
void drawUI()
{
gfx::clearBufferColor(0xFF3B3B3B);
ui::drawTitleBar("JKSV - 06/20/2018");
ui::drawTitleBar("JKSV - 06/22/2018");
switch(mstate)
{
@ -577,10 +577,12 @@ namespace ui
//Menu
titleMenu.print(16, 88, 0xFFFFFFFF, 424);
//Input guide
unsigned startX = 1056;
unsigned startX = 914;
buttonA.draw(startX, 672);
gfx::drawText("Select", startX += 38, 668, 32, 0xFFFFFFFF);
buttonB.draw(startX += 72, 672);
buttonY.draw(startX += 72, 672);
gfx::drawText("Dump All", startX += 38, 668, 32, 0xFFFFFFFF);
buttonB.draw(startX += 96, 672);
gfx::drawText("Back", startX += 38, 668, 32, 0xFFFFFFFF);
}
break;
@ -660,6 +662,10 @@ namespace ui
mstate = FLD_SEL;
}
}
else if(down & KEY_Y)
{
fs::dumpAllUserSaves(data::curUser);
}
else if(down & KEY_B)
mstate = USR_SEL;
@ -1007,7 +1013,7 @@ namespace ui
if(data::curData.getType() != FsSaveDataType_SystemSaveData)
{
keyboard getFolder;
std::string newFolder = getFolder.getString("");
std::string newFolder = util::safeString(getFolder.getString(""));
if(!newFolder.empty())
{
std::string folderPath = savePath + newFolder;
@ -1132,6 +1138,8 @@ namespace ui
sdList.reassign(sdPath);
util::copyDirListToMenu(sdList, sdMenu);
}
else if(advMenuCtrl == 2)
advMenuCtrl = advPrev;
}
else if(down & KEY_X)
{
@ -1166,15 +1174,15 @@ namespace ui
switch(advPrev)
{
case 0:
gfx::drawText("SAVE", 468, 256, 32, 0xFF000000);
gfx::drawText("SAVE", 472, 256, 32, 0xFF000000);
break;
case 1:
gfx::drawText("SDMC", 468, 256, 32, 0xFF000000);
gfx::drawText("SDMC", 472, 256, 32, 0xFF000000);
break;
}
copyMenu.print(468, 294, 0xFF000000, 300);
copyMenu.print(472, 294, 0xFF000000, 304);
}
}

View File

@ -9,6 +9,8 @@
#include "file.h"
#include "ui.h"
static const char verboten[] = { ',', '/', '\\', '<', '>', ':', '"', '|', '?', '*'};
namespace util
{
std::string getDateTime()
@ -87,4 +89,32 @@ namespace util
unsigned last = _path.find_last_of('/', _path.length() - 2);
_path.erase(last + 1, _path.length());
}
bool isVerboten(char t)
{
for(unsigned i = 0; i < 10; i++)
{
if(t == verboten[i])
return true;
}
return false;
}
std::string safeString(const std::string& s)
{
std::string ret = "";
for(unsigned i = 0; i < s.length(); i++)
{
if(isVerboten(s[i]))
{
ret += ' ';
}
else
ret += s[i];
}
return ret;
}
}