diff --git a/common/FileSystem.cpp b/common/FileSystem.cpp index e0918d78d6..7a1df96913 100644 --- a/common/FileSystem.cpp +++ b/common/FileSystem.cpp @@ -726,13 +726,6 @@ int FileSystem::FSeek64(std::FILE* fp, s64 offset, int whence) #ifdef _WIN32 return _fseeki64(fp, offset, whence); #else - // Prevent truncation on platforms which don't have a 64-bit off_t. - if constexpr (sizeof(off_t) != sizeof(s64)) - { - if (offset < std::numeric_limits::min() || offset > std::numeric_limits::max()) - return -1; - } - return fseeko(fp, static_cast(offset), whence); #endif } @@ -1474,6 +1467,9 @@ bool FileSystem::SetPathCompression(const char* path, bool enable) #else +// No 32-bit file offsets breaking stuff please. +static_assert(sizeof(off_t) == sizeof(s64)); + static u32 RecursiveFindFiles(const char* OriginPath, const char* ParentPath, const char* Path, const char* Pattern, u32 Flags, FileSystem::FindResultsArray* pResults) { @@ -1528,17 +1524,10 @@ static u32 RecursiveFindFiles(const char* OriginPath, const char* ParentPath, co FILESYSTEM_FIND_DATA outData; outData.Attributes = 0; -#if defined(__HAIKU__) || defined(__APPLE__) || defined(__FreeBSD__) struct stat sDir; if (stat(full_path.c_str(), &sDir) < 0) continue; -#else - struct stat64 sDir; - if (stat64(full_path.c_str(), &sDir) < 0) - continue; -#endif - if (S_ISDIR(sDir.st_mode)) { if (Flags & FILESYSTEM_FIND_RECURSIVE) @@ -1640,14 +1629,9 @@ bool FileSystem::StatFile(const char* path, FILESYSTEM_STAT_DATA* sd) if (path[0] == '\0') return false; - // stat file -#if defined(__HAIKU__) || defined(__APPLE__) || defined(__FreeBSD__) + // stat file struct stat sysStatData; if (stat(path, &sysStatData) < 0) -#else - struct stat64 sysStatData; - if (stat64(path, &sysStatData) < 0) -#endif return false; // parse attributes @@ -1673,14 +1657,9 @@ bool FileSystem::StatFile(std::FILE* fp, FILESYSTEM_STAT_DATA* sd) if (fd < 0) return false; - // stat file -#if defined(__HAIKU__) || defined(__APPLE__) || defined(__FreeBSD__) + // stat file struct stat sysStatData; if (fstat(fd, &sysStatData) < 0) -#else - struct stat64 sysStatData; - if (fstat64(fd, &sysStatData) < 0) -#endif return false; // parse attributes @@ -1706,14 +1685,9 @@ bool FileSystem::FileExists(const char* path) if (path[0] == '\0') return false; - // stat file -#if defined(__HAIKU__) || defined(__APPLE__) || defined(__FreeBSD__) + // stat file struct stat sysStatData; if (stat(path, &sysStatData) < 0) -#else - struct stat64 sysStatData; - if (stat64(path, &sysStatData) < 0) -#endif return false; if (S_ISDIR(sysStatData.st_mode)) @@ -1728,14 +1702,9 @@ bool FileSystem::DirectoryExists(const char* path) if (path[0] == '\0') return false; - // stat file -#if defined(__HAIKU__) || defined(__APPLE__) || defined(__FreeBSD__) + // stat file struct stat sysStatData; if (stat(path, &sysStatData) < 0) -#else - struct stat64 sysStatData; - if (stat64(path, &sysStatData) < 0) -#endif return false; if (S_ISDIR(sysStatData.st_mode)) diff --git a/common/Linux/LnxHostSys.cpp b/common/Linux/LnxHostSys.cpp index 5e64d4d9d4..a2fb2bff30 100644 --- a/common/Linux/LnxHostSys.cpp +++ b/common/Linux/LnxHostSys.cpp @@ -250,13 +250,9 @@ void* HostSys::CreateSharedMemory(const char* name, size_t size) shm_unlink(name); // ensure it's the correct size -#if !defined(__APPLE__) && !defined(__FreeBSD__) - if (ftruncate64(fd, static_cast(size)) < 0) -#else if (ftruncate(fd, static_cast(size)) < 0) -#endif { - std::fprintf(stderr, "ftruncate64(%zu) failed: %d\n", size, errno); + std::fprintf(stderr, "ftruncate(%zu) failed: %d\n", size, errno); return nullptr; } diff --git a/pcsx2/Linux/LnxFlatFileReader.cpp b/pcsx2/Linux/LnxFlatFileReader.cpp index 2ecc9f2a5f..a37082c35a 100644 --- a/pcsx2/Linux/LnxFlatFileReader.cpp +++ b/pcsx2/Linux/LnxFlatFileReader.cpp @@ -88,7 +88,6 @@ void FlatFileReader::CancelRead(void) void FlatFileReader::Close(void) { - if (m_fd != -1) close(m_fd); @@ -100,15 +99,9 @@ void FlatFileReader::Close(void) uint FlatFileReader::GetBlockCount(void) const { -#if defined(__HAIKU__) || defined(__APPLE__) || defined(__FreeBSD__) struct stat sysStatData; if (fstat(m_fd, &sysStatData) < 0) return 0; -#else - struct stat64 sysStatData; - if (fstat64(m_fd, &sysStatData) < 0) - return 0; -#endif - return (int)(sysStatData.st_size / m_blocksize); + return static_cast(sysStatData.st_size / m_blocksize); }