mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Also support atomic windows readAt
This commit is contained in:
parent
3c3596dbf2
commit
3f63c29736
2 changed files with 19 additions and 1 deletions
|
@ -60,6 +60,7 @@ inline u64 __rotr64(u64 x, unsigned int shift){
|
|||
}
|
||||
|
||||
#else // WIN32
|
||||
#include <io.h>
|
||||
|
||||
// Function Cross-Compatibility
|
||||
#define strcasecmp _stricmp
|
||||
|
@ -75,6 +76,7 @@ inline u64 __rotr64(u64 x, unsigned int shift){
|
|||
#define ftello _ftelli64
|
||||
#define atoll _atoi64
|
||||
#define fileno _fileno
|
||||
#define fileno_to_handle _get_osfhandle
|
||||
#if _M_IX86
|
||||
#define Crash() {__asm int 3}
|
||||
#else
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
#include "file/file_util.h"
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Core/FileLoaders/LocalFileLoader.h"
|
||||
#ifdef _WIN32
|
||||
#include "Common/CommonWindows.h"
|
||||
#endif
|
||||
|
||||
LocalFileLoader::LocalFileLoader(const std::string &filename)
|
||||
: fd_(0), f_(nullptr), filesize_(0), filename_(filename) {
|
||||
|
@ -73,5 +76,18 @@ std::string LocalFileLoader::Path() const {
|
|||
}
|
||||
|
||||
size_t LocalFileLoader::ReadAt(s64 absolutePos, size_t bytes, size_t count, void *data, Flags flags) {
|
||||
return pread(fd_, data, bytes * count, absolutePos) / bytes;
|
||||
#ifndef _WIN32
|
||||
return pread(fd_, data, bytes * count, absolutePos) / bytes;
|
||||
#else
|
||||
DWORD read = -1;
|
||||
intptr_t handle = fileno_to_handle(fd_);
|
||||
if (handle == 0) {
|
||||
return -1;
|
||||
}
|
||||
OVERLAPPED offset = { 0 };
|
||||
offset.Offset = (DWORD)(absolutePos & 0xffffffff);
|
||||
offset.OffsetHigh = (DWORD)((absolutePos & 0xffffffff00000000) >> 32);
|
||||
auto result = ReadFile((HANDLE)handle, data, bytes * count, &read, &offset);
|
||||
return result == TRUE ? (size_t)read / bytes : -1;
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue