Small changes to make Common and Core build under my preliminary UWP setup.

This commit is contained in:
Henrik Rydgard
2017-02-24 18:59:41 +01:00
parent 89ac1a5c4a
commit fcbc20f240
27 changed files with 178 additions and 45 deletions
+20 -5
View File
@@ -15,6 +15,8 @@
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include "ppsspp_config.h"
#include <limits>
#include "file/free.h"
#include "file/zip_read.h"
@@ -215,8 +217,13 @@ bool DirectoryFileHandle::Open(std::string &basePath, std::string &fileName, Fil
} else {
openmode = OPEN_EXISTING;
}
//Let's do it!
// Let's do it!
#if PPSSPP_PLATFORM(UWP)
hFile = CreateFile2(ConvertUTF8ToWString(fullName).c_str(), desired, sharemode, openmode, nullptr);
#else
hFile = CreateFile(ConvertUTF8ToWString(fullName).c_str(), desired, sharemode, 0, openmode, 0, 0);
#endif
bool success = hFile != INVALID_HANDLE_VALUE;
if (!success) {
DWORD w32err = GetLastError();
@@ -224,7 +231,11 @@ bool DirectoryFileHandle::Open(std::string &basePath, std::string &fileName, Fil
if (w32err == ERROR_SHARING_VIOLATION) {
// Sometimes, the file is locked for write, let's try again.
sharemode |= FILE_SHARE_WRITE;
#if PPSSPP_PLATFORM(UWP)
hFile = CreateFile2(ConvertUTF8ToWString(fullName).c_str(), desired, sharemode, openmode, nullptr);
#else
hFile = CreateFile(ConvertUTF8ToWString(fullName).c_str(), desired, sharemode, 0, openmode, 0, 0);
#endif
success = hFile != INVALID_HANDLE_VALUE;
if (!success) {
w32err = GetLastError();
@@ -380,8 +391,12 @@ size_t DirectoryFileHandle::Seek(s32 position, FileMove type)
case FILEMOVE_CURRENT: moveMethod = FILE_CURRENT; break;
case FILEMOVE_END: moveMethod = FILE_END; break;
}
DWORD newPos = SetFilePointer(hFile, (LONG)position, 0, moveMethod);
return newPos;
LARGE_INTEGER distance;
distance.QuadPart = position;
LARGE_INTEGER cursor;
DWORD newPos = SetFilePointerEx(hFile, distance, &cursor, moveMethod);
return cursor.QuadPart;
#else
int moveMethod = 0;
switch (type) {
@@ -512,7 +527,7 @@ int DirectoryFileSystem::RenameFile(const std::string &from, const std::string &
const char * fullToC = fullTo.c_str();
#ifdef _WIN32
bool retValue = (MoveFile(ConvertUTF8ToWString(fullFrom).c_str(), ConvertUTF8ToWString(fullToC).c_str()) == TRUE);
bool retValue = (MoveFileEx(ConvertUTF8ToWString(fullFrom).c_str(), ConvertUTF8ToWString(fullToC).c_str(), 0) == TRUE);
#else
bool retValue = (0 == rename(fullFrom.c_str(), fullToC));
#endif
@@ -742,7 +757,7 @@ std::vector<PSPFileInfo> DirectoryFileSystem::GetDirListing(std::string path) {
std::string w32path = GetLocalPath(path) + "\\*.*";
hFind = FindFirstFile(ConvertUTF8ToWString(w32path).c_str(), &findData);
hFind = FindFirstFileEx(ConvertUTF8ToWString(w32path).c_str(), FindExInfoStandard, &findData, FindExSearchNameMatch, NULL, 0);
if (hFind == INVALID_HANDLE_VALUE) {
return myVector; //the empty list