mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
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,16 +104,13 @@ 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);
|
||||
|
||||
ReturnValue = GetDeviceID();
|
||||
m_FileLength = File::GetSize(m_Filename.c_str());
|
||||
ReturnValue = GetDeviceID();
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG(WII_IPC_FILEIO, " failed - File doesn't exist");
|
||||
ReturnValue = -106;
|
||||
LOG(WII_IPC_FILEIO, " failed - File doesn't exist");
|
||||
ReturnValue = -106;
|
||||
}
|
||||
|
||||
Memory::Write_U32(ReturnValue, _CommandAddress+4);
|
||||
@ -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
|
||||
@ -212,8 +212,8 @@ CWII_IPC_HLE_Device_FileIO::IOCtl(u32 _CommandAddress)
|
||||
{
|
||||
case ISFS_IOCTL_GETFILESTATS:
|
||||
{
|
||||
u32 Position = (u32)ftell(m_pFileHandle);
|
||||
|
||||
u32 Position = (u32)ftell(m_pFileHandle);
|
||||
|
||||
u32 BufferOut = Memory::Read_U32(_CommandAddress + 0x18);
|
||||
LOG(WII_IPC_FILEIO, "FileIO: ISFS_IOCTL_GETFILESTATS");
|
||||
LOG(WII_IPC_FILEIO, " Length: %i Seek: %i", m_FileLength, Position);
|
||||
@ -245,4 +245,4 @@ CWII_IPC_HLE_Device_FileIO::ReturnFileHandle()
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user