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:
parent
08a3b60f8c
commit
3d441febda
|
@ -94,6 +94,8 @@ char* strndup (char const *s, size_t n);
|
||||||
#define ftell _ftelli64
|
#define ftell _ftelli64
|
||||||
#define atoll _atoi64
|
#define atoll _atoi64
|
||||||
#define stat64 _stat64
|
#define stat64 _stat64
|
||||||
|
#define fstat64 _fstat64
|
||||||
|
#define fileno _fileno
|
||||||
|
|
||||||
#if _M_IX86
|
#if _M_IX86
|
||||||
#define Crash() {__asm int 3}
|
#define Crash() {__asm int 3}
|
||||||
|
|
|
@ -345,6 +345,24 @@ u64 GetSize(const char *filename)
|
||||||
return 0;
|
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
|
// creates an empty file filename, returns true on success
|
||||||
bool CreateEmptyFile(const char *filename)
|
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");
|
FILE *f = fopen(filename, text_file ? "r" : "rb");
|
||||||
if (!f)
|
if (!f)
|
||||||
return false;
|
return false;
|
||||||
fseek(f, 0, SEEK_END);
|
size_t len = (size_t)GetSize(f);
|
||||||
size_t len = (size_t)ftell(f);
|
|
||||||
fseek(f, 0, SEEK_SET);
|
|
||||||
char *buf = new char[len + 1];
|
char *buf = new char[len + 1];
|
||||||
buf[fread(buf, 1, len, f)] = 0;
|
buf[fread(buf, 1, len, f)] = 0;
|
||||||
str = std::string(buf, len);
|
str = std::string(buf, len);
|
||||||
|
|
|
@ -78,6 +78,12 @@ bool IsDirectory(const char *filename);
|
||||||
// Returns the size of filename (64bit)
|
// Returns the size of filename (64bit)
|
||||||
u64 GetSize(const char *filename);
|
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.
|
// Returns true if successful, or path already exists.
|
||||||
bool CreateDir(const char *filename);
|
bool CreateDir(const char *filename);
|
||||||
|
|
||||||
|
|
|
@ -21,15 +21,14 @@
|
||||||
#include "Boot_ELF.h"
|
#include "Boot_ELF.h"
|
||||||
#include "Boot_WiiWAD.h"
|
#include "Boot_WiiWAD.h"
|
||||||
#include "ElfReader.h"
|
#include "ElfReader.h"
|
||||||
|
#include "FileUtil.h"
|
||||||
|
|
||||||
bool CBoot::IsElfWii(const char *filename)
|
bool CBoot::IsElfWii(const char *filename)
|
||||||
{
|
{
|
||||||
/* We already check if filename existed before we called this function, so
|
/* We already check if filename existed before we called this function, so
|
||||||
there is no need for another check, just read the file right away */
|
there is no need for another check, just read the file right away */
|
||||||
FILE *f = fopen(filename, "rb");
|
FILE *f = fopen(filename, "rb");
|
||||||
fseek(f, 0, SEEK_END);
|
u64 filesize = File::GetSize(f);
|
||||||
u64 filesize = ftell(f);
|
|
||||||
fseek(f, 0, SEEK_SET);
|
|
||||||
u8 *mem = new u8[(size_t)filesize];
|
u8 *mem = new u8[(size_t)filesize];
|
||||||
fread(mem, 1, (size_t)filesize, f);
|
fread(mem, 1, (size_t)filesize, f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
@ -46,9 +45,7 @@ bool CBoot::IsElfWii(const char *filename)
|
||||||
bool CBoot::Boot_ELF(const char *filename)
|
bool CBoot::Boot_ELF(const char *filename)
|
||||||
{
|
{
|
||||||
FILE *f = fopen(filename, "rb");
|
FILE *f = fopen(filename, "rb");
|
||||||
fseek(f, 0, SEEK_END);
|
u64 filesize = File::GetSize(f);
|
||||||
u64 filesize = ftell(f);
|
|
||||||
fseek(f, 0, SEEK_SET);
|
|
||||||
u8 *mem = new u8[(size_t)filesize];
|
u8 *mem = new u8[(size_t)filesize];
|
||||||
fread(mem, 1, (size_t)filesize, f);
|
fread(mem, 1, (size_t)filesize, f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "Dump.h"
|
#include "Dump.h"
|
||||||
|
#include "FileUtil.h"
|
||||||
|
|
||||||
CDump::CDump(const char* _szFilename) :
|
CDump::CDump(const char* _szFilename) :
|
||||||
m_pData(NULL),
|
m_pData(NULL),
|
||||||
|
@ -26,9 +27,7 @@ CDump::CDump(const char* _szFilename) :
|
||||||
FILE* pStream = fopen(_szFilename, "rb");
|
FILE* pStream = fopen(_szFilename, "rb");
|
||||||
if (pStream != NULL)
|
if (pStream != NULL)
|
||||||
{
|
{
|
||||||
fseek(pStream, 0, SEEK_END);
|
m_size = (size_t)File::GetSize(pStream);
|
||||||
m_size = (size_t) ftell(pStream);
|
|
||||||
fseek(pStream, 0, SEEK_SET);
|
|
||||||
|
|
||||||
m_pData = new u8[m_size];
|
m_pData = new u8[m_size];
|
||||||
|
|
||||||
|
|
|
@ -100,11 +100,6 @@ int CSIDevice_GCController::RunBuffer(u8* _pBuffer, int _iLength)
|
||||||
iPosition = _iLength;
|
iPosition = _iLength;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// WII Something - this could be bogus
|
|
||||||
case 0xCE:
|
|
||||||
WARN_LOG(SERIALINTERFACE, "Unknown Wii SI Command");
|
|
||||||
break;
|
|
||||||
|
|
||||||
// DEFAULT
|
// DEFAULT
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
|
|
|
@ -353,9 +353,7 @@ void LoadStateCallback(u64 userdata, int cyclesLate)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fseek(f, 0, SEEK_END);
|
sz = (int)(File::GetSize(f) - sizeof(state_header));
|
||||||
sz = (int)(ftell(f) - sizeof(state_header));
|
|
||||||
fseek(f, sizeof(state_header), SEEK_SET);
|
|
||||||
buffer = new u8[sz];
|
buffer = new u8[sz];
|
||||||
int x;
|
int x;
|
||||||
if ((x = (int)fread(buffer, 1, sz, f)) != (int)sz)
|
if ((x = (int)fread(buffer, 1, sz, f)) != (int)sz)
|
||||||
|
@ -455,9 +453,7 @@ void VerifyStateCallback(u64 userdata, int cyclesLate)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fseek(f, 0, SEEK_END);
|
sz = (int)(File::GetSize(f) - sizeof(int));
|
||||||
sz = (int)(ftell(f) - sizeof(int));
|
|
||||||
fseek(f, sizeof(int), SEEK_SET);
|
|
||||||
buffer = new u8[sz];
|
buffer = new u8[sz];
|
||||||
int x;
|
int x;
|
||||||
if ((x = (int)fread(buffer, 1, sz, f)) != (int)sz)
|
if ((x = (int)fread(buffer, 1, sz, f)) != (int)sz)
|
||||||
|
|
|
@ -343,9 +343,7 @@ bool DSPDisassembler::DisFile(const char* name, int base_addr, int pass, std::st
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fseek(in, 0, SEEK_END);
|
int size = (int)File::GetSize(in) & ~1;
|
||||||
int size = (int)ftell(in) & ~1;
|
|
||||||
fseek(in, 0, SEEK_SET);
|
|
||||||
u16 *binbuf = new u16[size / 2];
|
u16 *binbuf = new u16[size / 2];
|
||||||
fread(binbuf, 1, size, in);
|
fread(binbuf, 1, size, in);
|
||||||
fclose(in);
|
fclose(in);
|
||||||
|
|
|
@ -39,9 +39,7 @@ CompressedBlobReader::CompressedBlobReader(const char *filename)
|
||||||
{
|
{
|
||||||
file_name = filename;
|
file_name = filename;
|
||||||
file = fopen(filename, "rb");
|
file = fopen(filename, "rb");
|
||||||
fseek(file, 0, SEEK_END);
|
file_size = File::GetSize(filename);
|
||||||
file_size = ftell(file);
|
|
||||||
fseek(file, 0, SEEK_SET);
|
|
||||||
fread(&header, sizeof(CompressedBlobHeader), 1, file);
|
fread(&header, sizeof(CompressedBlobHeader), 1, file);
|
||||||
|
|
||||||
SetSectorSize(header.block_size);
|
SetSectorSize(header.block_size);
|
||||||
|
@ -190,14 +188,11 @@ bool CompressFileToBlob(const char* infile, const char* outfile, u32 sub_type,
|
||||||
|
|
||||||
callback("Files opened, ready to compress.", 0, arg);
|
callback("Files opened, ready to compress.", 0, arg);
|
||||||
|
|
||||||
fseek(inf, 0, SEEK_END);
|
|
||||||
s64 insize = ftell(inf);
|
|
||||||
fseek(inf, 0, SEEK_SET);
|
|
||||||
CompressedBlobHeader header;
|
CompressedBlobHeader header;
|
||||||
header.magic_cookie = kBlobCookie;
|
header.magic_cookie = kBlobCookie;
|
||||||
header.sub_type = sub_type;
|
header.sub_type = sub_type;
|
||||||
header.block_size = block_size;
|
header.block_size = block_size;
|
||||||
header.data_size = insize;
|
header.data_size = File::GetSize(infile);
|
||||||
|
|
||||||
// round upwards!
|
// round upwards!
|
||||||
header.num_blocks = (u32)((header.data_size + (block_size - 1)) / block_size);
|
header.num_blocks = (u32)((header.data_size + (block_size - 1)) / block_size);
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include "Blob.h"
|
#include "Blob.h"
|
||||||
#include "FileBlob.h"
|
#include "FileBlob.h"
|
||||||
|
#include "FileUtil.h"
|
||||||
|
|
||||||
namespace DiscIO
|
namespace DiscIO
|
||||||
{
|
{
|
||||||
|
@ -26,9 +27,7 @@ namespace DiscIO
|
||||||
PlainFileReader::PlainFileReader(FILE* file__)
|
PlainFileReader::PlainFileReader(FILE* file__)
|
||||||
{
|
{
|
||||||
file_ = file__;
|
file_ = file__;
|
||||||
fseek(file_, 0, SEEK_END);
|
size = File::GetSize(file__);
|
||||||
size = ftell(file_);
|
|
||||||
fseek(file_, 0, SEEK_SET);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PlainFileReader* PlainFileReader::Create(const char* filename)
|
PlainFileReader* PlainFileReader::Create(const char* filename)
|
||||||
|
|
|
@ -129,7 +129,7 @@ std::string CVolumeGC::GetApploaderDate() const
|
||||||
u64 CVolumeGC::GetSize() const
|
u64 CVolumeGC::GetSize() const
|
||||||
{
|
{
|
||||||
if (m_pReader)
|
if (m_pReader)
|
||||||
return (size_t)m_pReader->GetDataSize();
|
return m_pReader->GetDataSize();
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -269,10 +269,7 @@ bool DolphinApp::OnInit()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *tmpChar;
|
char *tmpChar;
|
||||||
long len;
|
size_t len = (size_t)File::GetSize(workingDir);
|
||||||
fseek(workingDir, 0, SEEK_END);
|
|
||||||
len = ftell(workingDir);
|
|
||||||
fseek(workingDir, 0, SEEK_SET);
|
|
||||||
tmpChar = new char[len];
|
tmpChar = new char[len];
|
||||||
fread(tmpChar, len, 1, workingDir);
|
fread(tmpChar, len, 1, workingDir);
|
||||||
fclose(workingDir);
|
fclose(workingDir);
|
||||||
|
|
Loading…
Reference in New Issue