UWP support

This commit is contained in:
Jack Andersen 2017-12-05 17:22:03 -10:00
parent cf3baad905
commit da9699a7e2
5 changed files with 29 additions and 2 deletions

View File

@ -178,6 +178,9 @@ macro(atdna out)
get_property(cdefs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY COMPILE_DEFINITIONS)
set(cdefcli "")
foreach(def ${cdefs})
if(def MATCHES "^WINAPI_FAMILY.*")
continue() # C++/CX gives clang a stomach ache
endif()
list(APPEND cdefcli "-D${def}")
endforeach()

View File

@ -8,6 +8,12 @@
#ifdef _MSC_VER
#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>
#if !defined(S_ISREG) && defined(S_IFMT) && defined(S_IFREG)

View File

@ -128,7 +128,9 @@ bool FileInfo::touch() const
HANDLE fh;
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);
if (fh == INVALID_HANDLE_VALUE)
return false;
@ -168,6 +170,7 @@ bool FileInfo::touch() const
}
CloseHandle(fh);
#endif
#elif (defined(HW_RVL) || defined(HW_DOL)) && defined(GEKKO)
// Generic portable version, not extremely reliable but does work
atUint64 val = 0xCDCDCDCDCD;

View File

@ -38,8 +38,13 @@ void FileReader::open()
int attempt = 0;
do
{
#if WINDOWS_STORE
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);
if (m_fileHandle == INVALID_HANDLE_VALUE)

View File

@ -37,13 +37,23 @@ void FileWriter::open(bool overwrite)
if (overwrite)
{
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,
nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
#endif
}
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,
nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
#endif
}
} while (m_fileHandle == INVALID_HANDLE_VALUE && attempt++ < 100);