mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-11-23 19:59:16 +01:00
-fixed wrong percentage displayed when copying gamecube games
from usb to sd which are in fst format -fixed a possible bug in deleting folders and files
This commit is contained in:
parent
21938074f3
commit
ce8d2f1641
@ -27,13 +27,13 @@ en exposed s_fsop fsop structure can be used by callback to update operation sta
|
||||
|
||||
static u8 *buff = NULL;
|
||||
static FILE *fs = NULL, *ft = NULL;
|
||||
static u32 bytes;
|
||||
static u32 block = 32768;
|
||||
static u32 blockIdx = 0;
|
||||
static u32 blockInfo[2] = {0,0};
|
||||
static u32 blockReady = 0;
|
||||
static s32 stopThread;
|
||||
static u64 folderSize = 0;
|
||||
u64 FolderProgressBytes;
|
||||
|
||||
// return false if the file doesn't exist
|
||||
bool fsop_GetFileSizeBytes(char *path, size_t *filesize) // for me stats st_size report always 0 :(
|
||||
@ -81,9 +81,7 @@ u64 fsop_GetFolderBytes (char *source)
|
||||
|
||||
// If it is a folder... recurse...
|
||||
if(fsop_DirExist(newSource))
|
||||
{
|
||||
bytes += fsop_GetFolderBytes(newSource);
|
||||
}
|
||||
else // It is a file !
|
||||
{
|
||||
size_t s;
|
||||
@ -160,7 +158,8 @@ static void *thread_CopyFileReader()
|
||||
SET(blockInfo[blockIdx], rb);
|
||||
SET(blockReady, 1);
|
||||
|
||||
while (blockReady && !stopThread) usleep(1);
|
||||
while(blockReady && !stopThread)
|
||||
usleep(1);
|
||||
}
|
||||
while(stopThread == 0);
|
||||
|
||||
@ -180,9 +179,7 @@ bool fsop_CopyFile(char *source, char *target, progress_callback_t spinner, void
|
||||
|
||||
fs = fopen(source, "rb");
|
||||
if(!fs)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ft = fopen(target, "wt");
|
||||
if(!ft)
|
||||
@ -216,6 +213,7 @@ bool fsop_CopyFile(char *source, char *target, progress_callback_t spinner, void
|
||||
blockReady = 0;
|
||||
blockInfo[0] = 0;
|
||||
blockInfo[1] = 0;
|
||||
u32 bytes = 0;
|
||||
|
||||
threadStack = MEM2_alloc(STACKSIZE);
|
||||
if(threadStack == NULL)
|
||||
@ -229,7 +227,8 @@ bool fsop_CopyFile(char *source, char *target, progress_callback_t spinner, void
|
||||
u32 bi;
|
||||
do
|
||||
{
|
||||
while (!blockReady) usleep (1); // Let's wait for incoming block from the thread
|
||||
while(!blockReady)
|
||||
usleep(1); // Let's wait for incoming block from the thread
|
||||
|
||||
bi = blockIdx;
|
||||
|
||||
@ -241,12 +240,15 @@ bool fsop_CopyFile(char *source, char *target, progress_callback_t spinner, void
|
||||
// write current block
|
||||
wb = fwrite(&buff[bi*block], 1, rb, ft);
|
||||
|
||||
if (wb != wb) err = 1;
|
||||
if (rb == 0) err = 1;
|
||||
bytes += rb;
|
||||
if(wb != wb || rb == 0)
|
||||
err = 1;
|
||||
|
||||
bytes += rb;
|
||||
if(spinner)
|
||||
spinner(bytes, folderSize, spinner_data);
|
||||
{
|
||||
FolderProgressBytes += rb;
|
||||
spinner(FolderProgressBytes, folderSize, spinner_data);
|
||||
}
|
||||
}
|
||||
while(bytes < size && err == 0);
|
||||
|
||||
@ -319,7 +321,7 @@ bool fsop_CopyFolder(char *source, char *target, progress_callback_t spinner, vo
|
||||
{
|
||||
gprintf("DML game USB->SD job started!\n");
|
||||
|
||||
bytes = 0;
|
||||
FolderProgressBytes = 0;
|
||||
folderSize = fsop_GetFolderBytes(source);
|
||||
return doCopyFolder(source, target, spinner, spinner_data);
|
||||
}
|
||||
@ -344,8 +346,7 @@ void fsop_deleteFolder(char *source)
|
||||
if(fsop_DirExist(newSource))
|
||||
fsop_deleteFolder(newSource);
|
||||
else // It is a file !
|
||||
gprintf("Deleting file: %s\n",newSource);
|
||||
remove(newSource);
|
||||
fsop_deleteFile(newSource);
|
||||
}
|
||||
closedir(pdir);
|
||||
gprintf("Deleting directory: %s\n",source);
|
||||
|
Loading…
Reference in New Issue
Block a user