mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2025-02-17 12:36:20 +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 u8 *buff = NULL;
|
||||||
static FILE *fs = NULL, *ft = NULL;
|
static FILE *fs = NULL, *ft = NULL;
|
||||||
static u32 bytes;
|
|
||||||
static u32 block = 32768;
|
static u32 block = 32768;
|
||||||
static u32 blockIdx = 0;
|
static u32 blockIdx = 0;
|
||||||
static u32 blockInfo[2] = {0,0};
|
static u32 blockInfo[2] = {0,0};
|
||||||
static u32 blockReady = 0;
|
static u32 blockReady = 0;
|
||||||
static s32 stopThread;
|
static s32 stopThread;
|
||||||
static u64 folderSize = 0;
|
static u64 folderSize = 0;
|
||||||
|
u64 FolderProgressBytes;
|
||||||
|
|
||||||
// return false if the file doesn't exist
|
// return false if the file doesn't exist
|
||||||
bool fsop_GetFileSizeBytes(char *path, size_t *filesize) // for me stats st_size report always 0 :(
|
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 it is a folder... recurse...
|
||||||
if(fsop_DirExist(newSource))
|
if(fsop_DirExist(newSource))
|
||||||
{
|
|
||||||
bytes += fsop_GetFolderBytes(newSource);
|
bytes += fsop_GetFolderBytes(newSource);
|
||||||
}
|
|
||||||
else // It is a file !
|
else // It is a file !
|
||||||
{
|
{
|
||||||
size_t s;
|
size_t s;
|
||||||
@ -160,7 +158,8 @@ static void *thread_CopyFileReader()
|
|||||||
SET(blockInfo[blockIdx], rb);
|
SET(blockInfo[blockIdx], rb);
|
||||||
SET(blockReady, 1);
|
SET(blockReady, 1);
|
||||||
|
|
||||||
while (blockReady && !stopThread) usleep(1);
|
while(blockReady && !stopThread)
|
||||||
|
usleep(1);
|
||||||
}
|
}
|
||||||
while(stopThread == 0);
|
while(stopThread == 0);
|
||||||
|
|
||||||
@ -180,9 +179,7 @@ bool fsop_CopyFile(char *source, char *target, progress_callback_t spinner, void
|
|||||||
|
|
||||||
fs = fopen(source, "rb");
|
fs = fopen(source, "rb");
|
||||||
if(!fs)
|
if(!fs)
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
ft = fopen(target, "wt");
|
ft = fopen(target, "wt");
|
||||||
if(!ft)
|
if(!ft)
|
||||||
@ -216,6 +213,7 @@ bool fsop_CopyFile(char *source, char *target, progress_callback_t spinner, void
|
|||||||
blockReady = 0;
|
blockReady = 0;
|
||||||
blockInfo[0] = 0;
|
blockInfo[0] = 0;
|
||||||
blockInfo[1] = 0;
|
blockInfo[1] = 0;
|
||||||
|
u32 bytes = 0;
|
||||||
|
|
||||||
threadStack = MEM2_alloc(STACKSIZE);
|
threadStack = MEM2_alloc(STACKSIZE);
|
||||||
if(threadStack == NULL)
|
if(threadStack == NULL)
|
||||||
@ -229,7 +227,8 @@ bool fsop_CopyFile(char *source, char *target, progress_callback_t spinner, void
|
|||||||
u32 bi;
|
u32 bi;
|
||||||
do
|
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;
|
bi = blockIdx;
|
||||||
|
|
||||||
@ -241,12 +240,15 @@ bool fsop_CopyFile(char *source, char *target, progress_callback_t spinner, void
|
|||||||
// write current block
|
// write current block
|
||||||
wb = fwrite(&buff[bi*block], 1, rb, ft);
|
wb = fwrite(&buff[bi*block], 1, rb, ft);
|
||||||
|
|
||||||
if (wb != wb) err = 1;
|
if(wb != wb || rb == 0)
|
||||||
if (rb == 0) err = 1;
|
err = 1;
|
||||||
bytes += rb;
|
|
||||||
|
|
||||||
|
bytes += rb;
|
||||||
if(spinner)
|
if(spinner)
|
||||||
spinner(bytes, folderSize, spinner_data);
|
{
|
||||||
|
FolderProgressBytes += rb;
|
||||||
|
spinner(FolderProgressBytes, folderSize, spinner_data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
while(bytes < size && err == 0);
|
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");
|
gprintf("DML game USB->SD job started!\n");
|
||||||
|
|
||||||
bytes = 0;
|
FolderProgressBytes = 0;
|
||||||
folderSize = fsop_GetFolderBytes(source);
|
folderSize = fsop_GetFolderBytes(source);
|
||||||
return doCopyFolder(source, target, spinner, spinner_data);
|
return doCopyFolder(source, target, spinner, spinner_data);
|
||||||
}
|
}
|
||||||
@ -344,8 +346,7 @@ void fsop_deleteFolder(char *source)
|
|||||||
if(fsop_DirExist(newSource))
|
if(fsop_DirExist(newSource))
|
||||||
fsop_deleteFolder(newSource);
|
fsop_deleteFolder(newSource);
|
||||||
else // It is a file !
|
else // It is a file !
|
||||||
gprintf("Deleting file: %s\n",newSource);
|
fsop_deleteFile(newSource);
|
||||||
remove(newSource);
|
|
||||||
}
|
}
|
||||||
closedir(pdir);
|
closedir(pdir);
|
||||||
gprintf("Deleting directory: %s\n",source);
|
gprintf("Deleting directory: %s\n",source);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user