mirror of https://github.com/libAthena/athena.git
UWP support
This commit is contained in:
parent
cf3baad905
commit
da9699a7e2
|
@ -178,6 +178,9 @@ macro(atdna out)
|
||||||
get_property(cdefs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY COMPILE_DEFINITIONS)
|
get_property(cdefs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY COMPILE_DEFINITIONS)
|
||||||
set(cdefcli "")
|
set(cdefcli "")
|
||||||
foreach(def ${cdefs})
|
foreach(def ${cdefs})
|
||||||
|
if(def MATCHES "^WINAPI_FAMILY.*")
|
||||||
|
continue() # C++/CX gives clang a stomach ache
|
||||||
|
endif()
|
||||||
list(APPEND cdefcli "-D${def}")
|
list(APPEND cdefcli "-D${def}")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,12 @@
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(disable : 4996)
|
#pragma warning(disable : 4996)
|
||||||
|
|
||||||
|
#if defined(WINAPI_FAMILY) && WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP
|
||||||
|
#define WINDOWS_STORE 1
|
||||||
|
#else
|
||||||
|
#define WINDOWS_STORE 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#if !defined(S_ISREG) && defined(S_IFMT) && defined(S_IFREG)
|
#if !defined(S_ISREG) && defined(S_IFMT) && defined(S_IFREG)
|
||||||
|
|
|
@ -128,7 +128,9 @@ bool FileInfo::touch() const
|
||||||
HANDLE fh;
|
HANDLE fh;
|
||||||
wchar_t date[80], time[80];
|
wchar_t date[80], time[80];
|
||||||
|
|
||||||
|
#if !WINDOWS_STORE
|
||||||
fh = CreateFileA(m_path.c_str(), GENERIC_READ | FILE_WRITE_ATTRIBUTES, 0, NULL, CREATE_NEW, 0, NULL);
|
fh = CreateFileA(m_path.c_str(), GENERIC_READ | FILE_WRITE_ATTRIBUTES, 0, NULL, CREATE_NEW, 0, NULL);
|
||||||
|
|
||||||
if (fh == INVALID_HANDLE_VALUE)
|
if (fh == INVALID_HANDLE_VALUE)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -168,6 +170,7 @@ bool FileInfo::touch() const
|
||||||
}
|
}
|
||||||
|
|
||||||
CloseHandle(fh);
|
CloseHandle(fh);
|
||||||
|
#endif
|
||||||
#elif (defined(HW_RVL) || defined(HW_DOL)) && defined(GEKKO)
|
#elif (defined(HW_RVL) || defined(HW_DOL)) && defined(GEKKO)
|
||||||
// Generic portable version, not extremely reliable but does work
|
// Generic portable version, not extremely reliable but does work
|
||||||
atUint64 val = 0xCDCDCDCDCD;
|
atUint64 val = 0xCDCDCDCDCD;
|
||||||
|
|
|
@ -38,8 +38,13 @@ void FileReader::open()
|
||||||
int attempt = 0;
|
int attempt = 0;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
m_fileHandle = CreateFileW(m_filename.c_str(), GENERIC_READ, FILE_SHARE_READ,
|
#if WINDOWS_STORE
|
||||||
nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
|
m_fileHandle = CreateFile2(m_filename.c_str(), GENERIC_READ, FILE_SHARE_READ,
|
||||||
|
OPEN_EXISTING, nullptr);
|
||||||
|
#else
|
||||||
|
m_fileHandle = CreateFileW(m_filename.c_str(), GENERIC_READ, FILE_SHARE_READ,
|
||||||
|
nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||||
|
#endif
|
||||||
} while (m_fileHandle == INVALID_HANDLE_VALUE && attempt++ < 100);
|
} while (m_fileHandle == INVALID_HANDLE_VALUE && attempt++ < 100);
|
||||||
|
|
||||||
if (m_fileHandle == INVALID_HANDLE_VALUE)
|
if (m_fileHandle == INVALID_HANDLE_VALUE)
|
||||||
|
|
|
@ -37,13 +37,23 @@ void FileWriter::open(bool overwrite)
|
||||||
if (overwrite)
|
if (overwrite)
|
||||||
{
|
{
|
||||||
std::wstring tmpFilename = m_filename + L'~';
|
std::wstring tmpFilename = m_filename + L'~';
|
||||||
|
#if WINDOWS_STORE
|
||||||
|
m_fileHandle = CreateFile2(tmpFilename.c_str(), GENERIC_WRITE, FILE_SHARE_WRITE,
|
||||||
|
CREATE_ALWAYS, nullptr);
|
||||||
|
#else
|
||||||
m_fileHandle = CreateFileW(tmpFilename.c_str(), GENERIC_WRITE, FILE_SHARE_WRITE,
|
m_fileHandle = CreateFileW(tmpFilename.c_str(), GENERIC_WRITE, FILE_SHARE_WRITE,
|
||||||
nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
|
nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#if WINDOWS_STORE
|
||||||
|
m_fileHandle = CreateFile2(m_filename.c_str(), GENERIC_WRITE, FILE_SHARE_WRITE,
|
||||||
|
OPEN_ALWAYS, nullptr);
|
||||||
|
#else
|
||||||
m_fileHandle = CreateFileW(m_filename.c_str(), GENERIC_WRITE, FILE_SHARE_WRITE,
|
m_fileHandle = CreateFileW(m_filename.c_str(), GENERIC_WRITE, FILE_SHARE_WRITE,
|
||||||
nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
|
nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} while (m_fileHandle == INVALID_HANDLE_VALUE && attempt++ < 100);
|
} while (m_fileHandle == INVALID_HANDLE_VALUE && attempt++ < 100);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue