Tidy up a little

This commit is contained in:
J-D-K
2018-09-22 17:19:57 -04:00
parent 6f5bd864f2
commit e10123a437
3 changed files with 14 additions and 43 deletions

View File

@@ -52,9 +52,6 @@ namespace data
std::string getTitle() { return title;}
std::string getTitleSafe() { return titleSafe; }
//Just for testing to make sure only ASCII folders
void debugCreate(const uint64_t& _id, const std::string& t);
//for disabling certain things
void setType(FsSaveDataType _type){ type = _type; }

View File

@@ -46,7 +46,7 @@ static int getUserIndex(const u128& id)
static std::vector<uint64_t> blacklist;
bool blacklisted(const uint64_t& id)
static bool blacklisted(const uint64_t& id)
{
for(unsigned i = 0; i < blacklist.size(); i++)
{
@@ -67,7 +67,6 @@ namespace data
void loadDataInfo()
{
blacklist.clear();
loadBlacklist();
icn defIcon;
@@ -79,13 +78,11 @@ namespace data
users.clear();
Result res = 0;
FsSaveDataIterator saveIt;
size_t total = 0;
FsSaveDataInfo info;
res = fsOpenSaveDataIterator(&saveIt, FsSaveDataSpaceId_All);
if(R_FAILED(res))
if(R_FAILED(fsOpenSaveDataIterator(&saveIt, FsSaveDataSpaceId_All)))
{
printf("SaveDataIterator Failed\n");
return;
@@ -93,10 +90,10 @@ namespace data
while(true)
{
res = fsSaveDataIteratorRead(&saveIt, &info, 1, &total);
if(R_FAILED(res) || total == 0)
if(R_FAILED(fsSaveDataIteratorRead(&saveIt, &info, 1, &total)) || total == 0)
break;
//If save data, not black listed or just ignore
if((info.SaveDataType == FsSaveDataType_SaveData && !blacklisted(info.titleID)) || sysSave)
{
int u = getUserIndex(info.userID);
@@ -250,21 +247,6 @@ namespace data
return false;
}
//ASCII Testing
void titledata::debugCreate(const uint64_t& _id, const std::string& t)
{
id = _id;
title = t;
titleSafe = util::safeString(t);
if(titleSafe.empty())
{
char tmp[18];
sprintf(tmp, "%016lX", id);
titleSafe.assign(tmp);
}
}
bool user::init(const u128& _id)
{
Result res = 0;
@@ -333,6 +315,7 @@ namespace data
void loadBlacklist()
{
blacklist.clear();
if(fs::fileExists(fs::getWorkDir() + "blacklist.txt"))
{
std::string line;

View File

@@ -28,26 +28,21 @@ namespace fs
bool mountSave(data::user& usr, data::titledata& open)
{
FsFileSystem sv;
Result res = 0;
if(open.getType() == FsSaveDataType_SaveData)
{
res = fsMount_SaveData(&sv, open.getID(), usr.getUID());
if(R_FAILED(res))
return false;
if(R_FAILED(fsMount_SaveData(&sv, open.getID(), usr.getUID())))
return false;
int r = fsdevMountDevice("sv", sv);
if(r == -1)
if(fsdevMountDevice("sv", sv) == -1)
return false;
}
else if(data::sysSave)
{
res = fsMount_SystemSaveData(&sv, open.getID());
if(R_FAILED(res))
if(R_FAILED(fsMount_SystemSaveData(&sv, open.getID())))
return false;
int r = fsdevMountDevice("sv", sv);
if(r == -1)
if(fsdevMountDevice("sv", sv) == -1)
return false;
}
@@ -99,10 +94,7 @@ namespace fs
{
std::string fullPath = path + item[index];
struct stat s;
if(stat(fullPath.c_str(), &s) == 0 && S_ISDIR(s.st_mode))
return true;
return false;
return stat(fullPath.c_str(), &s) == 0 && S_ISDIR(s.st_mode);
}
unsigned dirList::getCount()
@@ -187,9 +179,8 @@ namespace fs
f.close();
t.close();
Result res = fsdevCommitDevice(dev.c_str());
if(R_FAILED(res))
ui::showError("Error committing file to device", res);
if(R_FAILED(fsdevCommitDevice(dev.c_str())))
ui::showMessage("Error committing file to device!");
}
void copyDirToDir(const std::string& from, const std::string& to)
@@ -249,7 +240,7 @@ namespace fs
{
if(list.isDir(i))
{
std::string newPath = path + list.getItem(i) + "/";s
std::string newPath = path + list.getItem(i) + "/";
delDir(newPath);
std::string delPath = path + list.getItem(i);