mirror of
https://github.com/dborth/snes9xgx.git
synced 2025-01-12 19:29:08 +01:00
file code suggestions from rodries
This commit is contained in:
parent
ff6541e476
commit
0695e04b42
@ -62,6 +62,7 @@ lwp_t devicethread = LWP_THREAD_NULL;
|
|||||||
static void *
|
static void *
|
||||||
devicecallback (void *arg)
|
devicecallback (void *arg)
|
||||||
{
|
{
|
||||||
|
sleep(1);
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
@ -76,7 +77,7 @@ devicecallback (void *arg)
|
|||||||
|
|
||||||
if(isMounted[METHOD_USB])
|
if(isMounted[METHOD_USB])
|
||||||
{
|
{
|
||||||
if(!usb->isInserted()) // check if the device was removed - doesn't work on USB!
|
if(!usb->isInserted()) // check if the device was removed
|
||||||
{
|
{
|
||||||
unmountRequired[METHOD_USB] = true;
|
unmountRequired[METHOD_USB] = true;
|
||||||
isMounted[METHOD_USB] = false;
|
isMounted[METHOD_USB] = false;
|
||||||
@ -103,7 +104,7 @@ devicecallback (void *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
usleep(500000); // suspend thread for 1/2 sec
|
sleep(1); // suspend thread for 1 sec
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -572,8 +573,17 @@ SaveFile (char * buffer, char *filepath, u32 datasize, int method, bool silent)
|
|||||||
|
|
||||||
if (file > 0)
|
if (file > 0)
|
||||||
{
|
{
|
||||||
written = fwrite (savebuffer, 1, datasize, file);
|
u32 writesize, nextwrite;
|
||||||
if(written < datasize) written = 0;
|
while(written < datasize)
|
||||||
|
{
|
||||||
|
if(datasize - written > 16*1024) nextwrite=16*1024;
|
||||||
|
else nextwrite = datasize-written;
|
||||||
|
writesize = fwrite (buffer+written, 1, nextwrite, file);
|
||||||
|
if(writesize != nextwrite) break; // write failure
|
||||||
|
written += writesize;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(written != datasize) written = 0;
|
||||||
fclose (file);
|
fclose (file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user