From 8e69d942e99cb3fbad30bafb5f442ac50396b194 Mon Sep 17 00:00:00 2001 From: Maarten ter Huurne Date: Tue, 26 Aug 2008 11:44:17 +0000 Subject: [PATCH] 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 --- Source/Core/Common/Src/MappedFile.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/Core/Common/Src/MappedFile.cpp b/Source/Core/Common/Src/MappedFile.cpp index 5788fca6a7..9142303adc 100644 --- a/Source/Core/Common/Src/MappedFile.cpp +++ b/Source/Core/Common/Src/MappedFile.cpp @@ -108,7 +108,8 @@ bool CMappedFile::Open(const char* filename) size = (u64)low | ((u64)high << 32); #elif POSIX fd = open(filename, O_RDONLY); - size = 0; //TODO + size = lseek(fd, 0, SEEK_END); + lseek(fd, 0, SEEK_SET); #endif return(true); @@ -167,7 +168,7 @@ u8* CMappedFile::Lock(u64 offset, u64 size) { u64 realOffset = offset & ~(granularity - 1); s64 difference = offset - realOffset; - u64 fake_size = ((offset & 4095) + size + 4095) & 4095; + u64 fake_size = (difference + size + granularity - 1) & ~(granularity - 1); #ifdef _WIN32 u8* realPtr = (u8*)MapViewOfFile(hFileMapping, FILE_MAP_READ, (DWORD)(realOffset >> 32), (DWORD)realOffset, (SIZE_T)(size));