mirror of
https://github.com/rvtr/TDT.git
synced 2025-10-31 13:51:07 -04:00
Backups work reliably now
This commit is contained in:
parent
0c2c664882
commit
464fbd6151
@ -214,7 +214,7 @@ static bool delete(Menu* m)
|
|||||||
bool choice = NO;
|
bool choice = NO;
|
||||||
{
|
{
|
||||||
char str[] = "Are you sure you want to delete\n";
|
char str[] = "Are you sure you want to delete\n";
|
||||||
char* msg = (char*)malloc(strlen(str) + strlen(fpath) + 1);
|
char* msg = (char*)malloc(strlen(str) + strlen(fpath) + 4);
|
||||||
sprintf(msg, "%s\n%s", str, fpath);
|
sprintf(msg, "%s\n%s", str, fpath);
|
||||||
|
|
||||||
choice = choiceBox(msg);
|
choice = choiceBox(msg);
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
#include "maketmd.h"
|
#include "maketmd.h"
|
||||||
#include "rom.h"
|
#include "rom.h"
|
||||||
#include "storage.h"
|
#include "storage.h"
|
||||||
|
#include <errno.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
static bool _titleIsUsed(tDSiHeader* h)
|
static bool _titleIsUsed(tDSiHeader* h)
|
||||||
@ -437,6 +438,8 @@ bool install(char* fpath, bool systemTitle)
|
|||||||
iprintf("Failed\n");
|
iprintf("Failed\n");
|
||||||
iprintf("\x1B[33m"); //yellow
|
iprintf("\x1B[33m"); //yellow
|
||||||
|
|
||||||
|
iprintf("%s\n", strerror(errno));
|
||||||
|
/*
|
||||||
switch (result)
|
switch (result)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
@ -455,7 +458,7 @@ bool install(char* fpath, bool systemTitle)
|
|||||||
iprintf("Error opening output file.\n");
|
iprintf("Error opening output file.\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
iprintf("\x1B[47m"); //white
|
iprintf("\x1B[47m"); //white
|
||||||
|
|
||||||
goto error;
|
goto error;
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
#include "message.h"
|
#include "message.h"
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#define VERSION "0.6.8"
|
#define VERSION "0.6.8.1"
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
MAIN_MENU_INSTALL,
|
MAIN_MENU_INSTALL,
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
#include "storage.h"
|
#include "storage.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
|
#include <errno.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
|
||||||
#define TITLE_LIMIT 39
|
#define TITLE_LIMIT 39
|
||||||
@ -100,6 +101,9 @@ int copyFilePart(char const* src, u32 offset, u32 size, char const* dst)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (fileExists(dst))
|
||||||
|
remove(dst);
|
||||||
|
|
||||||
FILE* fout = fopen(dst, "wb");
|
FILE* fout = fopen(dst, "wb");
|
||||||
|
|
||||||
if (!fout)
|
if (!fout)
|
||||||
@ -115,7 +119,7 @@ int copyFilePart(char const* src, u32 offset, u32 size, char const* dst)
|
|||||||
consoleSelect(&topScreen);
|
consoleSelect(&topScreen);
|
||||||
|
|
||||||
int bytesRead;
|
int bytesRead;
|
||||||
unsigned int totalBytesRead = 0;
|
unsigned long long totalBytesRead = 0;
|
||||||
|
|
||||||
#define BUFF_SIZE 128 //Arbitrary. A value too large freezes the ds.
|
#define BUFF_SIZE 128 //Arbitrary. A value too large freezes the ds.
|
||||||
char* buffer = (char*)malloc(BUFF_SIZE);
|
char* buffer = (char*)malloc(BUFF_SIZE);
|
||||||
@ -228,10 +232,10 @@ bool copyDir(char const* src, char const* dst)
|
|||||||
|
|
||||||
if (ent->d_type == DT_DIR)
|
if (ent->d_type == DT_DIR)
|
||||||
{
|
{
|
||||||
char* dsrc = (char*)malloc(strlen(src) + strlen(ent->d_name) + 1);
|
char* dsrc = (char*)malloc(strlen(src) + strlen(ent->d_name) + 4);
|
||||||
sprintf(dsrc, "%s/%s", src, ent->d_name);
|
sprintf(dsrc, "%s/%s", src, ent->d_name);
|
||||||
|
|
||||||
char* ddst = (char*)malloc(strlen(dst) + strlen(ent->d_name) + 1);
|
char* ddst = (char*)malloc(strlen(dst) + strlen(ent->d_name) + 4);
|
||||||
sprintf(ddst, "%s/%s", dst, ent->d_name);
|
sprintf(ddst, "%s/%s", dst, ent->d_name);
|
||||||
|
|
||||||
mkdir(ddst, 0777);
|
mkdir(ddst, 0777);
|
||||||
@ -243,14 +247,14 @@ bool copyDir(char const* src, char const* dst)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char* fsrc = (char*)malloc(strlen(src) + strlen(ent->d_name) + 1);
|
char* fsrc = (char*)malloc(strlen(src) + strlen(ent->d_name) + 4);
|
||||||
sprintf(fsrc, "%s/%s", src, ent->d_name);
|
sprintf(fsrc, "%s/%s", src, ent->d_name);
|
||||||
|
|
||||||
char* fdst = (char*)malloc(strlen(dst) + strlen(ent->d_name) + 1);
|
char* fdst = (char*)malloc(strlen(dst) + strlen(ent->d_name) + 4);
|
||||||
sprintf(fdst, "%s/%s", dst, ent->d_name);
|
sprintf(fdst, "%s/%s", dst, ent->d_name);
|
||||||
|
|
||||||
// iprintf("%s\n%s\n\n", fsrc, fdst);
|
// iprintf("%s\n%s\n\n", fsrc, fdst);
|
||||||
iprintf("%s...", fdst);
|
iprintf("%s -> \n%s...", fsrc, fdst);
|
||||||
|
|
||||||
int ret = copyFile(fsrc, fdst);
|
int ret = copyFile(fsrc, fdst);
|
||||||
|
|
||||||
@ -260,6 +264,8 @@ bool copyDir(char const* src, char const* dst)
|
|||||||
iprintf("Fail\n");
|
iprintf("Fail\n");
|
||||||
iprintf("\x1B[33m"); //yellow
|
iprintf("\x1B[33m"); //yellow
|
||||||
|
|
||||||
|
iprintf("%s\n", strerror(errno));
|
||||||
|
/*
|
||||||
switch (ret)
|
switch (ret)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
@ -278,7 +284,7 @@ bool copyDir(char const* src, char const* dst)
|
|||||||
iprintf("Error opening output file.\n");
|
iprintf("Error opening output file.\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
iprintf("\x1B[47m"); //white
|
iprintf("\x1B[47m"); //white
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -302,9 +302,9 @@ static void backup(Menu* m)
|
|||||||
clearScreen(&bottomScreen);
|
clearScreen(&bottomScreen);
|
||||||
|
|
||||||
if (!copyDir(srcpath, dstpath))
|
if (!copyDir(srcpath, dstpath))
|
||||||
messagePrint("\nBackup error.");
|
messagePrint("\x1B[31m\nBackup error.\x1B[47m");
|
||||||
else
|
else
|
||||||
messagePrint("\nBackup finished.");
|
messagePrint("\x1B[42m\nBackup finished.\x1B[47m");
|
||||||
|
|
||||||
free(dstpath);
|
free(dstpath);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user