Implemented querying file size on POSIX. Also fixed size rounding of mmap() on POSIX.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@321 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Maarten ter Huurne 2008-08-26 11:44:17 +00:00
parent fdf02ce331
commit 8e69d942e9
1 changed files with 3 additions and 2 deletions

View File

@ -108,7 +108,8 @@ bool CMappedFile::Open(const char* filename)
size = (u64)low | ((u64)high << 32); size = (u64)low | ((u64)high << 32);
#elif POSIX #elif POSIX
fd = open(filename, O_RDONLY); fd = open(filename, O_RDONLY);
size = 0; //TODO size = lseek(fd, 0, SEEK_END);
lseek(fd, 0, SEEK_SET);
#endif #endif
return(true); return(true);
@ -167,7 +168,7 @@ u8* CMappedFile::Lock(u64 offset, u64 size)
{ {
u64 realOffset = offset & ~(granularity - 1); u64 realOffset = offset & ~(granularity - 1);
s64 difference = offset - realOffset; s64 difference = offset - realOffset;
u64 fake_size = ((offset & 4095) + size + 4095) & 4095; u64 fake_size = (difference + size + granularity - 1) & ~(granularity - 1);
#ifdef _WIN32 #ifdef _WIN32
u8* realPtr = (u8*)MapViewOfFile(hFileMapping, FILE_MAP_READ, (DWORD)(realOffset >> 32), (DWORD)realOffset, (SIZE_T)(size)); u8* realPtr = (u8*)MapViewOfFile(hFileMapping, FILE_MAP_READ, (DWORD)(realOffset >> 32), (DWORD)realOffset, (SIZE_T)(size));