Attempt to fix issue r3458. I don't have a 32bit linux install, however I know it will at least fix compressing. Please test if uncompressed games run.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6510 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Shawn Hoffman
2010-12-03 12:42:01 +00:00
parent 08a3b60f8c
commit 3d441febda
12 changed files with 42 additions and 42 deletions

View File

@ -94,6 +94,8 @@ char* strndup (char const *s, size_t n);
#define ftell _ftelli64
#define atoll _atoi64
#define stat64 _stat64
#define fstat64 _fstat64
#define fileno _fileno
#if _M_IX86
#define Crash() {__asm int 3}

View File

@ -345,6 +345,24 @@ u64 GetSize(const char *filename)
return 0;
}
// Overloaded GetSize, accepts file descriptor
u64 GetSize(const int fd)
{
struct stat64 buf;
if (fstat64(fd, &buf) != 0) {
ERROR_LOG(COMMON, "GetSize: stat failed %i: %s",
fd, GetLastErrorMsg());
return 0;
}
return buf.st_size;
}
// Overloaded GetSize, accepts FILE*
u64 GetSize(FILE *f)
{
return GetSize(fileno(f));
}
// creates an empty file filename, returns true on success
bool CreateEmptyFile(const char *filename)
{
@ -769,9 +787,7 @@ bool ReadFileToString(bool text_file, const char *filename, std::string &str)
FILE *f = fopen(filename, text_file ? "r" : "rb");
if (!f)
return false;
fseek(f, 0, SEEK_END);
size_t len = (size_t)ftell(f);
fseek(f, 0, SEEK_SET);
size_t len = (size_t)GetSize(f);
char *buf = new char[len + 1];
buf[fread(buf, 1, len, f)] = 0;
str = std::string(buf, len);

View File

@ -78,6 +78,12 @@ bool IsDirectory(const char *filename);
// Returns the size of filename (64bit)
u64 GetSize(const char *filename);
// Overloaded GetSize, accepts file descriptor
u64 GetSize(const int fd);
// Overloaded GetSize, accepts FILE*
u64 GetSize(FILE *f);
// Returns true if successful, or path already exists.
bool CreateDir(const char *filename);