linux fixes
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1335 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
2f528a3de4
commit
cf2468ec4d
|
@ -32,6 +32,9 @@
|
|||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include <fstream>
|
||||
|
||||
|
||||
namespace File
|
||||
{
|
||||
|
||||
|
@ -221,6 +224,52 @@ bool Copy(const char *srcFilename, const char *destFilename)
|
|||
return CopyFile(srcFilename, destFilename, FALSE);
|
||||
#else
|
||||
|
||||
#define BSIZE 1024
|
||||
|
||||
int rnum, wnum, err;
|
||||
char buffer[BSIZE];
|
||||
FILE *output, *input;
|
||||
|
||||
if (! (input = fopen(srcFilename, "r"))) {
|
||||
err = errno;
|
||||
PanicAlert("Error copying from %s: %s", srcFilename, strerror(err));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! (output = fopen(destFilename, "w"))) {
|
||||
err = errno;
|
||||
PanicAlert("Error copying to %s: %s", destFilename, strerror(err));
|
||||
return false;
|
||||
}
|
||||
|
||||
while(! feof(input)) {
|
||||
if((rnum = fread(buffer, sizeof(char), BSIZE, input)) != BSIZE) {
|
||||
if(ferror(input) != 0){
|
||||
PanicAlert("can't read source file\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if((wnum = fwrite(buffer, sizeof(char), rnum, output))!= rnum){
|
||||
PanicAlert("can't write output file\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(input);
|
||||
fclose(output);
|
||||
|
||||
return true;
|
||||
/*
|
||||
std::ifstream ifs(srcFilename, std::ios::binary);
|
||||
std::ofstream ofs(destFilename, std::ios::binary);
|
||||
|
||||
ofs << ifs.rdbuf();
|
||||
|
||||
ifs.close();
|
||||
ofs.close();
|
||||
|
||||
return true;*/
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -104,10 +104,7 @@ CWII_IPC_HLE_Device_FileIO::Open(u32 _CommandAddress, u32 _Mode)
|
|||
|
||||
if (m_pFileHandle != NULL)
|
||||
{
|
||||
fseek(m_pFileHandle, 0, SEEK_END);
|
||||
m_FileLength = (u32)ftell(m_pFileHandle);
|
||||
rewind(m_pFileHandle);
|
||||
|
||||
m_FileLength = File::GetSize(m_Filename.c_str());
|
||||
ReturnValue = GetDeviceID();
|
||||
}
|
||||
else
|
||||
|
@ -133,9 +130,12 @@ CWII_IPC_HLE_Device_FileIO::Seek(u32 _CommandAddress)
|
|||
switch(Mode)
|
||||
{
|
||||
case 0:
|
||||
fseek(m_pFileHandle, SeekPosition, SEEK_SET);
|
||||
if (fseek(m_pFileHandle, SeekPosition, SEEK_SET) == 0) {
|
||||
// Seek always return the seek position for success
|
||||
ReturnValue = SeekPosition;
|
||||
} else {
|
||||
LOG(WII_IPC_FILEIO, "FILEIO: Seek failed");
|
||||
}
|
||||
break;
|
||||
|
||||
case 1: // cur
|
||||
|
|
Loading…
Reference in New Issue