Skip to content

Commit

Permalink
Workaround for an edge case causing two backups to overwrite if you'r…
Browse files Browse the repository at this point in the history
…e doing a bacth backup and have a cartridge and an installed title of the same game.
  • Loading branch information
BernardoGiordano committed Oct 5, 2017
1 parent 7cf6563 commit e359d4d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
3 changes: 1 addition & 2 deletions include/datetime.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@

#include "common.h"

std::string getDate(void);
std::string getTime(void);
std::string getDateTime(void);
std::string getCleanDateTime(void);
std::string getPathDateTime(void);

#endif
15 changes: 5 additions & 10 deletions source/datetime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,28 @@

#include "datetime.h"

std::string getDate(void)
std::string getTime(void)
{
char buf[80] = {0};
time_t unixTime = time(NULL);
struct tm* timeStruct = gmtime((const time_t*)&unixTime);

sprintf(buf, "%i-%i-%i", timeStruct->tm_mday, timeStruct->tm_mon + 1, timeStruct->tm_year + 1900);
sprintf(buf, "%02i:%02i:%02i", timeStruct->tm_hour, timeStruct->tm_min, timeStruct->tm_sec);

std::string ret(buf);
return ret;
}

std::string getTime(void)
std::string getCleanDateTime(void)
{
char buf[80] = {0};
time_t unixTime = time(NULL);
struct tm* timeStruct = gmtime((const time_t*)&unixTime);

sprintf(buf, "%02i:%02i:%02i", timeStruct->tm_hour, timeStruct->tm_min, timeStruct->tm_sec);
sprintf(buf, "%02i%02i%02i_%02i%02i%02i", timeStruct->tm_mday, timeStruct->tm_mon + 1, timeStruct->tm_year + 1900, timeStruct->tm_hour, timeStruct->tm_min, timeStruct->tm_sec);

std::string ret(buf);
return ret;
}

std::string getDateTime(void)
{
return getDate() + " " + getTime();
return ret;
}

std::string getPathDateTime(void)
Expand Down
2 changes: 1 addition & 1 deletion source/fsstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void backup(size_t index)

if (R_SUCCEEDED(res))
{
std::string suggestion = multipleSelectionEnabled() ? title.getShortDescription() + " - Autobackup" : getPathDateTime();
std::string suggestion = multipleSelectionEnabled() ? title.getShortDescription() + " - Autobackup " + getCleanDateTime() : getPathDateTime();

std::u16string customPath;
if (multipleSelectionEnabled())
Expand Down

0 comments on commit e359d4d

Please sign in to comment.