mirror of https://github.com/AxioDL/nod.git
UWP support
This commit is contained in:
parent
63ae60a967
commit
3d70a568dc
|
@ -11,6 +11,11 @@
|
|||
#define NOMINMAX
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#if defined(WINAPI_FAMILY) && WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP
|
||||
#define WINDOWS_STORE 1
|
||||
#else
|
||||
#define WINDOWS_STORE 0
|
||||
#endif
|
||||
#else
|
||||
#include <ctype.h>
|
||||
#include <sys/file.h>
|
||||
|
|
|
@ -254,43 +254,6 @@ bool DiscBase::IPartition::extractSysFiles(SystemStringView basePath, const Extr
|
|||
return true;
|
||||
}
|
||||
|
||||
static uint64_t GetInode(const SystemChar* path)
|
||||
{
|
||||
uint64_t inode;
|
||||
#if _WIN32
|
||||
HANDLE fp = CreateFileW(path,
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
nullptr,
|
||||
OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
nullptr);
|
||||
if (!fp)
|
||||
{
|
||||
LogModule.report(logvisor::Error, _S("unable to open %s"), path);
|
||||
return 0;
|
||||
}
|
||||
BY_HANDLE_FILE_INFORMATION info;
|
||||
if (!GetFileInformationByHandle(fp, &info))
|
||||
{
|
||||
LogModule.report(logvisor::Error, _S("unable to GetFileInformationByHandle %s"), path);
|
||||
return 0;
|
||||
}
|
||||
inode = uint64_t(info.nFileIndexHigh) << 32;
|
||||
inode |= uint64_t(info.nFileIndexLow);
|
||||
CloseHandle(fp);
|
||||
#else
|
||||
struct stat st;
|
||||
if (stat(path, &st))
|
||||
{
|
||||
LogModule.report(logvisor::Error, _S("unable to stat %s"), path);
|
||||
return 0;
|
||||
}
|
||||
inode = uint64_t(st.st_ino);
|
||||
#endif
|
||||
return inode;
|
||||
}
|
||||
|
||||
static bool IsSystemFile(SystemStringView name, bool& isDol)
|
||||
{
|
||||
isDol = false;
|
||||
|
|
|
@ -17,8 +17,12 @@ public:
|
|||
|
||||
bool exists()
|
||||
{
|
||||
#if !WINDOWS_STORE
|
||||
HANDLE fp = CreateFileW(m_path.c_str(), GENERIC_READ, FILE_SHARE_READ,
|
||||
nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
#else
|
||||
HANDLE fp = CreateFile2(m_path.c_str(), GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr);
|
||||
#endif
|
||||
if (fp == INVALID_HANDLE_VALUE)
|
||||
return false;
|
||||
CloseHandle(fp);
|
||||
|
@ -27,8 +31,12 @@ public:
|
|||
|
||||
uint64_t size()
|
||||
{
|
||||
#if !WINDOWS_STORE
|
||||
HANDLE fp = CreateFileW(m_path.c_str(), GENERIC_READ, FILE_SHARE_READ,
|
||||
nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
#else
|
||||
HANDLE fp = CreateFile2(m_path.c_str(), GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr);
|
||||
#endif
|
||||
if (fp == INVALID_HANDLE_VALUE)
|
||||
return 0;
|
||||
LARGE_INTEGER sz;
|
||||
|
@ -48,8 +56,12 @@ public:
|
|||
WriteStream(SystemStringView path, int64_t maxWriteSize, bool& err)
|
||||
: m_maxWriteSize(maxWriteSize)
|
||||
{
|
||||
#if !WINDOWS_STORE
|
||||
fp = CreateFileW(path.data(), GENERIC_WRITE, FILE_SHARE_WRITE,
|
||||
nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
#else
|
||||
fp = CreateFile2(path.data(), GENERIC_WRITE, FILE_SHARE_WRITE, CREATE_ALWAYS, nullptr);
|
||||
#endif
|
||||
if (fp == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
LogModule.report(logvisor::Error, _S("unable to open '%s' for writing"), path.data());
|
||||
|
@ -59,8 +71,12 @@ public:
|
|||
WriteStream(SystemStringView path, uint64_t offset, int64_t maxWriteSize, bool& err)
|
||||
: m_maxWriteSize(maxWriteSize)
|
||||
{
|
||||
#if !WINDOWS_STORE
|
||||
fp = CreateFileW(path.data(), GENERIC_WRITE, FILE_SHARE_WRITE,
|
||||
nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
#else
|
||||
fp = CreateFile2(path.data(), GENERIC_WRITE, FILE_SHARE_WRITE, OPEN_ALWAYS, nullptr);
|
||||
#endif
|
||||
if (fp == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
LogModule.report(logvisor::Error, _S("unable to open '%s' for writing"), path.data());
|
||||
|
@ -116,8 +132,12 @@ public:
|
|||
HANDLE fp;
|
||||
ReadStream(SystemStringView path, bool& err)
|
||||
{
|
||||
#if !WINDOWS_STORE
|
||||
fp = CreateFileW(path.data(), GENERIC_READ, FILE_SHARE_READ,
|
||||
nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
#else
|
||||
fp = CreateFile2(path.data(), GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr);
|
||||
#endif
|
||||
if (fp == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
err = true;
|
||||
|
|
2
logvisor
2
logvisor
|
@ -1 +1 @@
|
|||
Subproject commit 59741b63b88ce6c1135733a326e3cbfaf8d22e0c
|
||||
Subproject commit 408ae926d76128fa23a12607d0a1e0a970ab3554
|
Loading…
Reference in New Issue