mirror of https://github.com/PCSX2/pcsx2.git
Misc: Drop stat compatibility calls
This commit is contained in:
parent
1f88072eae
commit
c16836e7c0
|
@ -726,13 +726,6 @@ int FileSystem::FSeek64(std::FILE* fp, s64 offset, int whence)
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
return _fseeki64(fp, offset, whence);
|
return _fseeki64(fp, offset, whence);
|
||||||
#else
|
#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<off_t>::min() || offset > std::numeric_limits<off_t>::max())
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return fseeko(fp, static_cast<off_t>(offset), whence);
|
return fseeko(fp, static_cast<off_t>(offset), whence);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1474,6 +1467,9 @@ bool FileSystem::SetPathCompression(const char* path, bool enable)
|
||||||
|
|
||||||
#else
|
#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,
|
static u32 RecursiveFindFiles(const char* OriginPath, const char* ParentPath, const char* Path, const char* Pattern,
|
||||||
u32 Flags, FileSystem::FindResultsArray* pResults)
|
u32 Flags, FileSystem::FindResultsArray* pResults)
|
||||||
{
|
{
|
||||||
|
@ -1528,17 +1524,10 @@ static u32 RecursiveFindFiles(const char* OriginPath, const char* ParentPath, co
|
||||||
FILESYSTEM_FIND_DATA outData;
|
FILESYSTEM_FIND_DATA outData;
|
||||||
outData.Attributes = 0;
|
outData.Attributes = 0;
|
||||||
|
|
||||||
#if defined(__HAIKU__) || defined(__APPLE__) || defined(__FreeBSD__)
|
|
||||||
struct stat sDir;
|
struct stat sDir;
|
||||||
if (stat(full_path.c_str(), &sDir) < 0)
|
if (stat(full_path.c_str(), &sDir) < 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
#else
|
|
||||||
struct stat64 sDir;
|
|
||||||
if (stat64(full_path.c_str(), &sDir) < 0)
|
|
||||||
continue;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (S_ISDIR(sDir.st_mode))
|
if (S_ISDIR(sDir.st_mode))
|
||||||
{
|
{
|
||||||
if (Flags & FILESYSTEM_FIND_RECURSIVE)
|
if (Flags & FILESYSTEM_FIND_RECURSIVE)
|
||||||
|
@ -1641,13 +1630,8 @@ bool FileSystem::StatFile(const char* path, FILESYSTEM_STAT_DATA* sd)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// stat file
|
// stat file
|
||||||
#if defined(__HAIKU__) || defined(__APPLE__) || defined(__FreeBSD__)
|
|
||||||
struct stat sysStatData;
|
struct stat sysStatData;
|
||||||
if (stat(path, &sysStatData) < 0)
|
if (stat(path, &sysStatData) < 0)
|
||||||
#else
|
|
||||||
struct stat64 sysStatData;
|
|
||||||
if (stat64(path, &sysStatData) < 0)
|
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// parse attributes
|
// parse attributes
|
||||||
|
@ -1674,13 +1658,8 @@ bool FileSystem::StatFile(std::FILE* fp, FILESYSTEM_STAT_DATA* sd)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// stat file
|
// stat file
|
||||||
#if defined(__HAIKU__) || defined(__APPLE__) || defined(__FreeBSD__)
|
|
||||||
struct stat sysStatData;
|
struct stat sysStatData;
|
||||||
if (fstat(fd, &sysStatData) < 0)
|
if (fstat(fd, &sysStatData) < 0)
|
||||||
#else
|
|
||||||
struct stat64 sysStatData;
|
|
||||||
if (fstat64(fd, &sysStatData) < 0)
|
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// parse attributes
|
// parse attributes
|
||||||
|
@ -1707,13 +1686,8 @@ bool FileSystem::FileExists(const char* path)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// stat file
|
// stat file
|
||||||
#if defined(__HAIKU__) || defined(__APPLE__) || defined(__FreeBSD__)
|
|
||||||
struct stat sysStatData;
|
struct stat sysStatData;
|
||||||
if (stat(path, &sysStatData) < 0)
|
if (stat(path, &sysStatData) < 0)
|
||||||
#else
|
|
||||||
struct stat64 sysStatData;
|
|
||||||
if (stat64(path, &sysStatData) < 0)
|
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (S_ISDIR(sysStatData.st_mode))
|
if (S_ISDIR(sysStatData.st_mode))
|
||||||
|
@ -1729,13 +1703,8 @@ bool FileSystem::DirectoryExists(const char* path)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// stat file
|
// stat file
|
||||||
#if defined(__HAIKU__) || defined(__APPLE__) || defined(__FreeBSD__)
|
|
||||||
struct stat sysStatData;
|
struct stat sysStatData;
|
||||||
if (stat(path, &sysStatData) < 0)
|
if (stat(path, &sysStatData) < 0)
|
||||||
#else
|
|
||||||
struct stat64 sysStatData;
|
|
||||||
if (stat64(path, &sysStatData) < 0)
|
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (S_ISDIR(sysStatData.st_mode))
|
if (S_ISDIR(sysStatData.st_mode))
|
||||||
|
|
|
@ -250,13 +250,9 @@ void* HostSys::CreateSharedMemory(const char* name, size_t size)
|
||||||
shm_unlink(name);
|
shm_unlink(name);
|
||||||
|
|
||||||
// ensure it's the correct size
|
// ensure it's the correct size
|
||||||
#if !defined(__APPLE__) && !defined(__FreeBSD__)
|
|
||||||
if (ftruncate64(fd, static_cast<off64_t>(size)) < 0)
|
|
||||||
#else
|
|
||||||
if (ftruncate(fd, static_cast<off_t>(size)) < 0)
|
if (ftruncate(fd, static_cast<off_t>(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;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,6 @@ void FlatFileReader::CancelRead(void)
|
||||||
|
|
||||||
void FlatFileReader::Close(void)
|
void FlatFileReader::Close(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (m_fd != -1)
|
if (m_fd != -1)
|
||||||
close(m_fd);
|
close(m_fd);
|
||||||
|
|
||||||
|
@ -100,15 +99,9 @@ void FlatFileReader::Close(void)
|
||||||
|
|
||||||
uint FlatFileReader::GetBlockCount(void) const
|
uint FlatFileReader::GetBlockCount(void) const
|
||||||
{
|
{
|
||||||
#if defined(__HAIKU__) || defined(__APPLE__) || defined(__FreeBSD__)
|
|
||||||
struct stat sysStatData;
|
struct stat sysStatData;
|
||||||
if (fstat(m_fd, &sysStatData) < 0)
|
if (fstat(m_fd, &sysStatData) < 0)
|
||||||
return 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<uint>(sysStatData.st_size / m_blocksize);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue