mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-01-18 22:35:39 +00:00
FileSystem: Add 64-bit fseek/ftell wrappers
This commit is contained in:
parent
cbf0a21f05
commit
c71f78ffa0
|
@ -500,6 +500,31 @@ std::FILE* OpenCFile(const char* filename, const char* mode)
|
|||
#endif
|
||||
}
|
||||
|
||||
int 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 (Android 32-bit).
|
||||
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);
|
||||
#endif
|
||||
}
|
||||
|
||||
s64 FTell64(std::FILE* fp)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return static_cast<s64>(_ftelli64(fp));
|
||||
#else
|
||||
return static_cast<s64>(ftello(fp));
|
||||
#endif
|
||||
}
|
||||
|
||||
std::optional<std::vector<u8>> ReadBinaryFile(const char* filename)
|
||||
{
|
||||
ManagedCFilePtr fp = OpenManagedCFile(filename, "rb");
|
||||
|
|
|
@ -183,6 +183,8 @@ std::unique_ptr<ByteStream> OpenFile(const char* FileName, u32 Flags);
|
|||
using ManagedCFilePtr = std::unique_ptr<std::FILE, void (*)(std::FILE*)>;
|
||||
ManagedCFilePtr OpenManagedCFile(const char* filename, const char* mode);
|
||||
std::FILE* OpenCFile(const char* filename, const char* mode);
|
||||
int FSeek64(std::FILE* fp, s64 offset, int whence);
|
||||
s64 FTell64(std::FILE* fp);
|
||||
|
||||
std::optional<std::vector<u8>> ReadBinaryFile(const char* filename);
|
||||
std::optional<std::vector<u8>> ReadBinaryFile(std::FILE* fp);
|
||||
|
|
Loading…
Reference in a new issue