mirror of https://github.com/PCSX2/pcsx2.git
Common: Remove unused code
This commit is contained in:
parent
76d3299690
commit
9655d28a23
|
@ -21,7 +21,7 @@
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(_UWP)
|
#if defined(_WIN32)
|
||||||
#include "RedtapeWindows.h"
|
#include "RedtapeWindows.h"
|
||||||
|
|
||||||
#include "StackWalker.h"
|
#include "StackWalker.h"
|
||||||
|
|
|
@ -31,8 +31,6 @@ std::unique_ptr<D3D12::Context> g_d3d12_context;
|
||||||
|
|
||||||
using namespace D3D12;
|
using namespace D3D12;
|
||||||
|
|
||||||
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
|
||||||
|
|
||||||
// Private D3D12 state
|
// Private D3D12 state
|
||||||
static HMODULE s_d3d12_library;
|
static HMODULE s_d3d12_library;
|
||||||
static PFN_D3D12_CREATE_DEVICE s_d3d12_create_device;
|
static PFN_D3D12_CREATE_DEVICE s_d3d12_create_device;
|
||||||
|
@ -74,21 +72,6 @@ static void UnloadD3D12Library()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
static const PFN_D3D12_CREATE_DEVICE s_d3d12_create_device = D3D12CreateDevice;
|
|
||||||
static const PFN_D3D12_GET_DEBUG_INTERFACE s_d3d12_get_debug_interface = D3D12GetDebugInterface;
|
|
||||||
static const PFN_D3D12_SERIALIZE_ROOT_SIGNATURE s_d3d12_serialize_root_signature = D3D12SerializeRootSignature;
|
|
||||||
|
|
||||||
static bool LoadD3D12Library()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void UnloadD3D12Library() {}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Context::Context() = default;
|
Context::Context() = default;
|
||||||
|
|
||||||
Context::~Context()
|
Context::~Context()
|
||||||
|
|
|
@ -23,10 +23,6 @@
|
||||||
|
|
||||||
#include <d3dcompiler.h>
|
#include <d3dcompiler.h>
|
||||||
|
|
||||||
#ifdef _UWP
|
|
||||||
#include <winrt/Windows.System.Profile.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace D3D12;
|
using namespace D3D12;
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
|
@ -45,22 +41,7 @@ struct CacheIndexEntry
|
||||||
};
|
};
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
static bool CanUsePipelineCache()
|
ShaderCache::ShaderCache() = default;
|
||||||
{
|
|
||||||
#ifdef _UWP
|
|
||||||
// GetCachedBlob crashes on XBox UWP for some reason...
|
|
||||||
const auto version_info = winrt::Windows::System::Profile::AnalyticsInfo::VersionInfo();
|
|
||||||
const auto device_family = version_info.DeviceFamily();
|
|
||||||
return (device_family != L"Windows.Xbox");
|
|
||||||
#else
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
ShaderCache::ShaderCache()
|
|
||||||
: m_use_pipeline_cache(CanUsePipelineCache())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
ShaderCache::~ShaderCache()
|
ShaderCache::~ShaderCache()
|
||||||
{
|
{
|
||||||
|
@ -111,7 +92,7 @@ bool ShaderCache::Open(std::string_view base_path, D3D_FEATURE_LEVEL feature_lev
|
||||||
result = CreateNew(shader_index_filename, shader_blob_filename, m_shader_index_file, m_shader_blob_file);
|
result = CreateNew(shader_index_filename, shader_blob_filename, m_shader_index_file, m_shader_blob_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_use_pipeline_cache && result)
|
if (result)
|
||||||
{
|
{
|
||||||
const std::string base_pipelines_filename = GetCacheBaseFileName(base_path, "pipelines", feature_level, debug);
|
const std::string base_pipelines_filename = GetCacheBaseFileName(base_path, "pipelines", feature_level, debug);
|
||||||
const std::string pipelines_index_filename = base_pipelines_filename + ".idx";
|
const std::string pipelines_index_filename = base_pipelines_filename + ".idx";
|
||||||
|
@ -143,14 +124,11 @@ void ShaderCache::InvalidatePipelineCache()
|
||||||
m_pipeline_index_file = nullptr;
|
m_pipeline_index_file = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_use_pipeline_cache)
|
const std::string base_pipelines_filename =
|
||||||
{
|
GetCacheBaseFileName(m_base_path, "pipelines", m_feature_level, m_debug);
|
||||||
const std::string base_pipelines_filename =
|
const std::string pipelines_index_filename = base_pipelines_filename + ".idx";
|
||||||
GetCacheBaseFileName(m_base_path, "pipelines", m_feature_level, m_debug);
|
const std::string pipelines_blob_filename = base_pipelines_filename + ".bin";
|
||||||
const std::string pipelines_index_filename = base_pipelines_filename + ".idx";
|
CreateNew(pipelines_index_filename, pipelines_blob_filename, m_pipeline_index_file, m_pipeline_blob_file);
|
||||||
const std::string pipelines_blob_filename = base_pipelines_filename + ".bin";
|
|
||||||
CreateNew(pipelines_index_filename, pipelines_blob_filename, m_pipeline_index_file, m_pipeline_blob_file);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShaderCache::CreateNew(const std::string& index_filename, const std::string& blob_filename, std::FILE*& index_file,
|
bool ShaderCache::CreateNew(const std::string& index_filename, const std::string& blob_filename, std::FILE*& index_file,
|
||||||
|
|
|
@ -48,7 +48,6 @@ namespace D3D12
|
||||||
|
|
||||||
__fi D3D_FEATURE_LEVEL GetFeatureLevel() const { return m_feature_level; }
|
__fi D3D_FEATURE_LEVEL GetFeatureLevel() const { return m_feature_level; }
|
||||||
__fi u32 GetDataVersion() const { return m_data_version; }
|
__fi u32 GetDataVersion() const { return m_data_version; }
|
||||||
__fi bool UsingPipelineCache() const { return m_use_pipeline_cache; }
|
|
||||||
__fi bool UsingDebugShaders() const { return m_debug; }
|
__fi bool UsingDebugShaders() const { return m_debug; }
|
||||||
|
|
||||||
bool Open(std::string_view base_path, D3D_FEATURE_LEVEL feature_level, u32 version, bool debug);
|
bool Open(std::string_view base_path, D3D_FEATURE_LEVEL feature_level, u32 version, bool debug);
|
||||||
|
@ -146,7 +145,6 @@ namespace D3D12
|
||||||
|
|
||||||
D3D_FEATURE_LEVEL m_feature_level = D3D_FEATURE_LEVEL_11_0;
|
D3D_FEATURE_LEVEL m_feature_level = D3D_FEATURE_LEVEL_11_0;
|
||||||
u32 m_data_version = 0;
|
u32 m_data_version = 0;
|
||||||
bool m_use_pipeline_cache = false;
|
|
||||||
bool m_debug = false;
|
bool m_debug = false;
|
||||||
};
|
};
|
||||||
} // namespace D3D12
|
} // namespace D3D12
|
||||||
|
|
|
@ -47,7 +47,7 @@ static std::mutex s_assertion_failed_mutex;
|
||||||
|
|
||||||
static inline void FreezeThreads(void** handle)
|
static inline void FreezeThreads(void** handle)
|
||||||
{
|
{
|
||||||
#if defined(_WIN32) && !defined(_UWP)
|
#if defined(_WIN32)
|
||||||
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
|
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
|
||||||
if (snapshot != INVALID_HANDLE_VALUE)
|
if (snapshot != INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
|
@ -77,7 +77,7 @@ static inline void FreezeThreads(void** handle)
|
||||||
|
|
||||||
static inline void ResumeThreads(void* handle)
|
static inline void ResumeThreads(void* handle)
|
||||||
{
|
{
|
||||||
#if defined(_WIN32) && !defined(_UWP)
|
#if defined(_WIN32)
|
||||||
if (handle != INVALID_HANDLE_VALUE)
|
if (handle != INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
THREADENTRY32 threadEntry;
|
THREADENTRY32 threadEntry;
|
||||||
|
@ -112,7 +112,7 @@ void pxOnAssertFail(const char* file, int line, const char* func, const char* ms
|
||||||
char full_msg[512];
|
char full_msg[512];
|
||||||
std::snprintf(full_msg, sizeof(full_msg), "%s:%d: assertion failed in function %s: %s\n", file, line, func, msg);
|
std::snprintf(full_msg, sizeof(full_msg), "%s:%d: assertion failed in function %s: %s\n", file, line, func, msg);
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(_UWP)
|
#if defined(_WIN32)
|
||||||
HANDLE error_handle = GetStdHandle(STD_ERROR_HANDLE);
|
HANDLE error_handle = GetStdHandle(STD_ERROR_HANDLE);
|
||||||
if (error_handle != INVALID_HANDLE_VALUE)
|
if (error_handle != INVALID_HANDLE_VALUE)
|
||||||
WriteConsoleA(GetStdHandle(STD_ERROR_HANDLE), full_msg, static_cast<DWORD>(std::strlen(full_msg)), NULL, NULL);
|
WriteConsoleA(GetStdHandle(STD_ERROR_HANDLE), full_msg, static_cast<DWORD>(std::strlen(full_msg)), NULL, NULL);
|
||||||
|
|
|
@ -39,19 +39,6 @@
|
||||||
#include <winioctl.h>
|
#include <winioctl.h>
|
||||||
#include <share.h>
|
#include <share.h>
|
||||||
#include <shlobj.h>
|
#include <shlobj.h>
|
||||||
|
|
||||||
#if defined(_UWP)
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <io.h>
|
|
||||||
#include <winrt/Windows.ApplicationModel.h>
|
|
||||||
#include <winrt/Windows.Devices.Enumeration.h>
|
|
||||||
#include <winrt/Windows.Foundation.Collections.h>
|
|
||||||
#include <winrt/Windows.Foundation.h>
|
|
||||||
#include <winrt/Windows.Storage.FileProperties.h>
|
|
||||||
#include <winrt/Windows.Storage.Search.h>
|
|
||||||
#include <winrt/Windows.Storage.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
@ -521,7 +508,7 @@ std::vector<std::string> FileSystem::GetRootDirectoryList()
|
||||||
{
|
{
|
||||||
std::vector<std::string> results;
|
std::vector<std::string> results;
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(_UWP)
|
#if defined(_WIN32)
|
||||||
char buf[256];
|
char buf[256];
|
||||||
const DWORD size = GetLogicalDriveStringsA(sizeof(buf), buf);
|
const DWORD size = GetLogicalDriveStringsA(sizeof(buf), buf);
|
||||||
if (size != 0 && size < (sizeof(buf) - 1))
|
if (size != 0 && size < (sizeof(buf) - 1))
|
||||||
|
@ -534,28 +521,6 @@ std::vector<std::string> FileSystem::GetRootDirectoryList()
|
||||||
ptr += len + 1u;
|
ptr += len + 1u;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#elif defined(_UWP)
|
|
||||||
if (const auto install_location = winrt::Windows::ApplicationModel::Package::Current().InstalledLocation();
|
|
||||||
install_location)
|
|
||||||
{
|
|
||||||
if (const auto path = install_location.Path(); !path.empty())
|
|
||||||
results.push_back(StringUtil::WideStringToUTF8String(path));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (const auto local_location = winrt::Windows::Storage::ApplicationData::Current().LocalFolder(); local_location)
|
|
||||||
{
|
|
||||||
if (const auto path = local_location.Path(); !path.empty())
|
|
||||||
results.push_back(StringUtil::WideStringToUTF8String(path));
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto devices = winrt::Windows::Storage::KnownFolders::RemovableDevices();
|
|
||||||
const auto folders_task(devices.GetFoldersAsync());
|
|
||||||
for (const auto& storage_folder : folders_task.get())
|
|
||||||
{
|
|
||||||
const auto path = storage_folder.Path();
|
|
||||||
if (!path.empty())
|
|
||||||
results.push_back(StringUtil::WideStringToUTF8String(path));
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
const char* home_path = std::getenv("HOME");
|
const char* home_path = std::getenv("HOME");
|
||||||
if (home_path)
|
if (home_path)
|
||||||
|
@ -595,127 +560,6 @@ std::string Path::Combine(const std::string_view& base, const std::string_view&
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _UWP
|
|
||||||
static std::FILE* OpenCFileUWP(const wchar_t* wfilename, const wchar_t* mode, FileSystem::FileShareMode share_mode)
|
|
||||||
{
|
|
||||||
DWORD access = 0;
|
|
||||||
DWORD share = 0;
|
|
||||||
DWORD disposition = 0;
|
|
||||||
|
|
||||||
switch (share_mode)
|
|
||||||
{
|
|
||||||
case FileSystem::FileShareMode::DenyNone:
|
|
||||||
share = FILE_SHARE_READ | FILE_SHARE_WRITE;
|
|
||||||
break;
|
|
||||||
case FileSystem::FileShareMode::DenyRead:
|
|
||||||
share = FILE_SHARE_WRITE;
|
|
||||||
break;
|
|
||||||
case FileSystem::FileShareMode::DenyWrite:
|
|
||||||
share = FILE_SHARE_READ;
|
|
||||||
break;
|
|
||||||
case FileSystem::FileShareMode::DenyReadWrite:
|
|
||||||
default:
|
|
||||||
share = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
int flags = 0;
|
|
||||||
const wchar_t* tmode = mode;
|
|
||||||
while (*tmode)
|
|
||||||
{
|
|
||||||
if (*tmode == L'r' && *(tmode + 1) == L'+')
|
|
||||||
{
|
|
||||||
access = GENERIC_READ | GENERIC_WRITE;
|
|
||||||
disposition = OPEN_EXISTING;
|
|
||||||
flags |= _O_RDWR;
|
|
||||||
tmode += 2;
|
|
||||||
}
|
|
||||||
else if (*tmode == L'w' && *(tmode + 1) == L'+')
|
|
||||||
{
|
|
||||||
access = GENERIC_READ | GENERIC_WRITE;
|
|
||||||
disposition = CREATE_ALWAYS;
|
|
||||||
flags |= _O_RDWR | _O_CREAT | _O_TRUNC;
|
|
||||||
tmode += 2;
|
|
||||||
}
|
|
||||||
else if (*tmode == L'a' && *(tmode + 1) == L'+')
|
|
||||||
{
|
|
||||||
access = GENERIC_READ | GENERIC_WRITE;
|
|
||||||
disposition = CREATE_ALWAYS;
|
|
||||||
flags |= _O_RDWR | _O_APPEND | _O_CREAT | _O_TRUNC;
|
|
||||||
tmode += 2;
|
|
||||||
}
|
|
||||||
else if (*tmode == L'r')
|
|
||||||
{
|
|
||||||
access = GENERIC_READ;
|
|
||||||
disposition = OPEN_EXISTING;
|
|
||||||
flags |= _O_RDONLY;
|
|
||||||
tmode++;
|
|
||||||
}
|
|
||||||
else if (*tmode == L'w')
|
|
||||||
{
|
|
||||||
access = GENERIC_WRITE;
|
|
||||||
disposition = CREATE_ALWAYS;
|
|
||||||
flags |= _O_WRONLY | _O_CREAT | _O_TRUNC;
|
|
||||||
tmode++;
|
|
||||||
}
|
|
||||||
else if (*tmode == L'a')
|
|
||||||
{
|
|
||||||
access = GENERIC_READ | GENERIC_WRITE;
|
|
||||||
disposition = CREATE_ALWAYS;
|
|
||||||
flags |= _O_WRONLY | _O_APPEND | _O_CREAT | _O_TRUNC;
|
|
||||||
tmode++;
|
|
||||||
}
|
|
||||||
else if (*tmode == L'b')
|
|
||||||
{
|
|
||||||
flags |= _O_BINARY;
|
|
||||||
tmode++;
|
|
||||||
}
|
|
||||||
else if (*tmode == L'S')
|
|
||||||
{
|
|
||||||
flags |= _O_SEQUENTIAL;
|
|
||||||
tmode++;
|
|
||||||
}
|
|
||||||
else if (*tmode == L'R')
|
|
||||||
{
|
|
||||||
flags |= _O_RANDOM;
|
|
||||||
tmode++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.Error("Unknown mode flags: '%s'", StringUtil::WideStringToUTF8String(mode).c_str());
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
HANDLE hFile = CreateFileFromAppW(wfilename, access, share, nullptr, disposition, 0, nullptr);
|
|
||||||
if (hFile == INVALID_HANDLE_VALUE)
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
if (flags & _O_APPEND && !SetFilePointerEx(hFile, LARGE_INTEGER{}, nullptr, FILE_END))
|
|
||||||
{
|
|
||||||
Console.Error("SetFilePointerEx() failed: %08X", GetLastError());
|
|
||||||
CloseHandle(hFile);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
int fd = _open_osfhandle(reinterpret_cast<intptr_t>(hFile), flags);
|
|
||||||
if (fd < 0)
|
|
||||||
{
|
|
||||||
CloseHandle(hFile);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::FILE* fp = _wfdopen(fd, mode);
|
|
||||||
if (!fp)
|
|
||||||
{
|
|
||||||
_close(fd);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return fp;
|
|
||||||
}
|
|
||||||
#endif // _UWP
|
|
||||||
|
|
||||||
std::FILE* FileSystem::OpenCFile(const char* filename, const char* mode)
|
std::FILE* FileSystem::OpenCFile(const char* filename, const char* mode)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -725,13 +569,7 @@ std::FILE* FileSystem::OpenCFile(const char* filename, const char* mode)
|
||||||
{
|
{
|
||||||
std::FILE* fp;
|
std::FILE* fp;
|
||||||
if (_wfopen_s(&fp, wfilename.c_str(), wmode.c_str()) != 0)
|
if (_wfopen_s(&fp, wfilename.c_str(), wmode.c_str()) != 0)
|
||||||
{
|
|
||||||
#ifdef _UWP
|
|
||||||
return OpenCFileUWP(wfilename.c_str(), wmode.c_str(), FileShareMode::DenyReadWrite);
|
|
||||||
#else
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
return fp;
|
return fp;
|
||||||
}
|
}
|
||||||
|
@ -751,10 +589,7 @@ int FileSystem::OpenFDFile(const char* filename, int flags, int mode)
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
const std::wstring wfilename(StringUtil::UTF8StringToWideString(filename));
|
const std::wstring wfilename(StringUtil::UTF8StringToWideString(filename));
|
||||||
if (!wfilename.empty())
|
if (!wfilename.empty())
|
||||||
{
|
|
||||||
// TODO: UWP
|
|
||||||
return _wopen(wfilename.c_str(), flags, mode);
|
return _wopen(wfilename.c_str(), flags, mode);
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
#else
|
#else
|
||||||
|
@ -797,11 +632,7 @@ std::FILE* FileSystem::OpenSharedCFile(const char* filename, const char* mode, F
|
||||||
if (fp)
|
if (fp)
|
||||||
return fp;
|
return fp;
|
||||||
|
|
||||||
#ifdef _UWP
|
|
||||||
return OpenCFileUWP(wfilename.c_str(), wmode.c_str(), share_mode);
|
|
||||||
#else
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
return std::fopen(filename, mode);
|
return std::fopen(filename, mode);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1027,19 +858,6 @@ static u32 TranslateWin32Attributes(u32 Win32Attributes)
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DWORD WrapGetFileAttributes(const wchar_t* path)
|
|
||||||
{
|
|
||||||
#ifndef _UWP
|
|
||||||
return GetFileAttributesW(path);
|
|
||||||
#else
|
|
||||||
WIN32_FILE_ATTRIBUTE_DATA fad;
|
|
||||||
if (!GetFileAttributesExFromAppW(path, GetFileExInfoStandard, &fad))
|
|
||||||
return INVALID_FILE_ATTRIBUTES;
|
|
||||||
|
|
||||||
return fad.dwFileAttributes;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static u32 RecursiveFindFiles(const char* origin_path, const char* parent_path, const char* path, const char* pattern,
|
static u32 RecursiveFindFiles(const char* origin_path, const char* parent_path, const char* path, const char* pattern,
|
||||||
u32 flags, FileSystem::FindResultsArray* results)
|
u32 flags, FileSystem::FindResultsArray* results)
|
||||||
{
|
{
|
||||||
|
@ -1061,13 +879,7 @@ static u32 RecursiveFindFiles(const char* origin_path, const char* parent_path,
|
||||||
std::string utf8_filename;
|
std::string utf8_filename;
|
||||||
utf8_filename.reserve((sizeof(wfd.cFileName) / sizeof(wfd.cFileName[0])) * 2);
|
utf8_filename.reserve((sizeof(wfd.cFileName) / sizeof(wfd.cFileName[0])) * 2);
|
||||||
|
|
||||||
#ifndef _UWP
|
|
||||||
HANDLE hFind = FindFirstFileW(StringUtil::UTF8StringToWideString(tempStr).c_str(), &wfd);
|
HANDLE hFind = FindFirstFileW(StringUtil::UTF8StringToWideString(tempStr).c_str(), &wfd);
|
||||||
#else
|
|
||||||
HANDLE hFind = FindFirstFileExFromAppW(StringUtil::UTF8StringToWideString(tempStr).c_str(), FindExInfoBasic, &wfd,
|
|
||||||
FindExSearchNameMatch, nullptr, 0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (hFind == INVALID_HANDLE_VALUE)
|
if (hFind == INVALID_HANDLE_VALUE)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -1249,7 +1061,6 @@ bool FileSystem::StatFile(const char* path, FILESYSTEM_STAT_DATA* sd)
|
||||||
if (wpath.empty())
|
if (wpath.empty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
#ifndef _UWP
|
|
||||||
// determine attributes for the path. if it's a directory, things have to be handled differently..
|
// determine attributes for the path. if it's a directory, things have to be handled differently..
|
||||||
DWORD fileAttributes = GetFileAttributesW(wpath.c_str());
|
DWORD fileAttributes = GetFileAttributesW(wpath.c_str());
|
||||||
if (fileAttributes == INVALID_FILE_ATTRIBUTES)
|
if (fileAttributes == INVALID_FILE_ATTRIBUTES)
|
||||||
|
@ -1289,17 +1100,6 @@ bool FileSystem::StatFile(const char* path, FILESYSTEM_STAT_DATA* sd)
|
||||||
sd->ModificationTime = ConvertFileTimeToUnixTime(bhfi.ftLastWriteTime);
|
sd->ModificationTime = ConvertFileTimeToUnixTime(bhfi.ftLastWriteTime);
|
||||||
sd->Size = static_cast<s64>(((u64)bhfi.nFileSizeHigh) << 32 | (u64)bhfi.nFileSizeLow);
|
sd->Size = static_cast<s64>(((u64)bhfi.nFileSizeHigh) << 32 | (u64)bhfi.nFileSizeLow);
|
||||||
return true;
|
return true;
|
||||||
#else
|
|
||||||
WIN32_FILE_ATTRIBUTE_DATA fad;
|
|
||||||
if (!GetFileAttributesExFromAppW(wpath, GetFileExInfoStandard, &fad))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
sd->Attributes = TranslateWin32Attributes(fad.dwFileAttributes);
|
|
||||||
sd->CreationTime = ConvertFileTimeToUnixTime(fad.ftCreationTime);
|
|
||||||
sd->ModificationTime = ConvertFileTimeToUnixTime(fad.ftLastWriteTime);
|
|
||||||
sd->Size = static_cast<s64>(((u64)fad.nFileSizeHigh) << 32 | (u64)fad.nFileSizeLow);
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileSystem::StatFile(std::FILE* fp, FILESYSTEM_STAT_DATA* sd)
|
bool FileSystem::StatFile(std::FILE* fp, FILESYSTEM_STAT_DATA* sd)
|
||||||
|
@ -1340,7 +1140,7 @@ bool FileSystem::FileExists(const char* path)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// determine attributes for the path. if it's a directory, things have to be handled differently..
|
// determine attributes for the path. if it's a directory, things have to be handled differently..
|
||||||
DWORD fileAttributes = WrapGetFileAttributes(wpath.c_str());
|
DWORD fileAttributes = GetFileAttributesW(wpath.c_str());
|
||||||
if (fileAttributes == INVALID_FILE_ATTRIBUTES)
|
if (fileAttributes == INVALID_FILE_ATTRIBUTES)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -1362,7 +1162,7 @@ bool FileSystem::DirectoryExists(const char* path)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// determine attributes for the path. if it's a directory, things have to be handled differently..
|
// determine attributes for the path. if it's a directory, things have to be handled differently..
|
||||||
DWORD fileAttributes = WrapGetFileAttributes(wpath.c_str());
|
DWORD fileAttributes = GetFileAttributesW(wpath.c_str());
|
||||||
if (fileAttributes == INVALID_FILE_ATTRIBUTES)
|
if (fileAttributes == INVALID_FILE_ATTRIBUTES)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -1378,11 +1178,7 @@ bool FileSystem::DirectoryIsEmpty(const char* path)
|
||||||
wpath += L"\\*";
|
wpath += L"\\*";
|
||||||
|
|
||||||
WIN32_FIND_DATAW wfd;
|
WIN32_FIND_DATAW wfd;
|
||||||
#ifndef _UWP
|
|
||||||
HANDLE hFind = FindFirstFileW(wpath.c_str(), &wfd);
|
HANDLE hFind = FindFirstFileW(wpath.c_str(), &wfd);
|
||||||
#else
|
|
||||||
HANDLE hFind = FindFirstFileExFromAppW(wpath.c_str(), FindExInfoBasic, &wfd, FindExSearchNameMatch, nullptr, 0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (hFind == INVALID_HANDLE_VALUE)
|
if (hFind == INVALID_HANDLE_VALUE)
|
||||||
return true;
|
return true;
|
||||||
|
@ -1411,14 +1207,9 @@ bool FileSystem::CreateDirectoryPath(const char* Path, bool Recursive)
|
||||||
if (wpath.empty())
|
if (wpath.empty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// try just flat-out, might work if there's no other segments that have to be made
|
// try just flat-out, might work if there's no other segments that have to be made
|
||||||
#ifndef _UWP
|
|
||||||
if (CreateDirectoryW(wpath.c_str(), nullptr))
|
if (CreateDirectoryW(wpath.c_str(), nullptr))
|
||||||
return true;
|
return true;
|
||||||
#else
|
|
||||||
if (CreateDirectoryFromAppW(wpath.c_str(), nullptr))
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!Recursive)
|
if (!Recursive)
|
||||||
return false;
|
return false;
|
||||||
|
@ -1428,7 +1219,7 @@ bool FileSystem::CreateDirectoryPath(const char* Path, bool Recursive)
|
||||||
if (lastError == ERROR_ALREADY_EXISTS)
|
if (lastError == ERROR_ALREADY_EXISTS)
|
||||||
{
|
{
|
||||||
// check the attributes
|
// check the attributes
|
||||||
u32 Attributes = WrapGetFileAttributes(wpath.c_str());
|
u32 Attributes = GetFileAttributesW(wpath.c_str());
|
||||||
if (Attributes != INVALID_FILE_ATTRIBUTES && Attributes & FILE_ATTRIBUTE_DIRECTORY)
|
if (Attributes != INVALID_FILE_ATTRIBUTES && Attributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
|
@ -1447,11 +1238,7 @@ bool FileSystem::CreateDirectoryPath(const char* Path, bool Recursive)
|
||||||
{
|
{
|
||||||
if (wpath[i] == L'\\' || wpath[i] == L'/')
|
if (wpath[i] == L'\\' || wpath[i] == L'/')
|
||||||
{
|
{
|
||||||
#ifndef _UWP
|
|
||||||
const BOOL result = CreateDirectoryW(tempPath.c_str(), nullptr);
|
const BOOL result = CreateDirectoryW(tempPath.c_str(), nullptr);
|
||||||
#else
|
|
||||||
const BOOL result = CreateDirectoryFromAppW(tempPath.c_str(), nullptr);
|
|
||||||
#endif
|
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
lastError = GetLastError();
|
lastError = GetLastError();
|
||||||
|
@ -1471,11 +1258,7 @@ bool FileSystem::CreateDirectoryPath(const char* Path, bool Recursive)
|
||||||
// re-create the end if it's not a separator, check / as well because windows can interpret them
|
// re-create the end if it's not a separator, check / as well because windows can interpret them
|
||||||
if (wpath[pathLength - 1] != L'\\' && wpath[pathLength - 1] != L'/')
|
if (wpath[pathLength - 1] != L'\\' && wpath[pathLength - 1] != L'/')
|
||||||
{
|
{
|
||||||
#ifndef _UWP
|
|
||||||
const BOOL result = CreateDirectoryW(wpath.c_str(), nullptr);
|
const BOOL result = CreateDirectoryW(wpath.c_str(), nullptr);
|
||||||
#else
|
|
||||||
const BOOL result = CreateDirectoryFromAppW(wpath.c_str(), nullptr);
|
|
||||||
#endif
|
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
lastError = GetLastError();
|
lastError = GetLastError();
|
||||||
|
@ -1500,15 +1283,11 @@ bool FileSystem::DeleteFilePath(const char* path)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const std::wstring wpath(StringUtil::UTF8StringToWideString(path));
|
const std::wstring wpath(StringUtil::UTF8StringToWideString(path));
|
||||||
const DWORD fileAttributes = WrapGetFileAttributes(wpath.c_str());
|
const DWORD fileAttributes = GetFileAttributesW(wpath.c_str());
|
||||||
if (fileAttributes == INVALID_FILE_ATTRIBUTES || fileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
if (fileAttributes == INVALID_FILE_ATTRIBUTES || fileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
#ifndef _UWP
|
|
||||||
return (DeleteFileW(wpath.c_str()) == TRUE);
|
return (DeleteFileW(wpath.c_str()) == TRUE);
|
||||||
#else
|
|
||||||
return (DeleteFileFromAppW(wpath.c_str()) == TRUE);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileSystem::RenamePath(const char* old_path, const char* new_path)
|
bool FileSystem::RenamePath(const char* old_path, const char* new_path)
|
||||||
|
@ -1516,29 +1295,11 @@ bool FileSystem::RenamePath(const char* old_path, const char* new_path)
|
||||||
const std::wstring old_wpath(StringUtil::UTF8StringToWideString(old_path));
|
const std::wstring old_wpath(StringUtil::UTF8StringToWideString(old_path));
|
||||||
const std::wstring new_wpath(StringUtil::UTF8StringToWideString(new_path));
|
const std::wstring new_wpath(StringUtil::UTF8StringToWideString(new_path));
|
||||||
|
|
||||||
#ifndef _UWP
|
|
||||||
if (!MoveFileExW(old_wpath.c_str(), new_wpath.c_str(), MOVEFILE_REPLACE_EXISTING))
|
if (!MoveFileExW(old_wpath.c_str(), new_wpath.c_str(), MOVEFILE_REPLACE_EXISTING))
|
||||||
{
|
{
|
||||||
Console.Error("MoveFileEx('%s', '%s') failed: %08X", old_path, new_path, GetLastError());
|
Console.Error("MoveFileEx('%s', '%s') failed: %08X", old_path, new_path, GetLastError());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
// try moving if it doesn't exist, since ReplaceFile fails on non-existing destinations
|
|
||||||
if (WrapGetFileAttributes(new_wpath.c_str()) != INVALID_FILE_ATTRIBUTES)
|
|
||||||
{
|
|
||||||
if (!DeleteFileFromAppW(new_wpath.c_str()))
|
|
||||||
{
|
|
||||||
Log_ErrorPrintf("DeleteFileFromAppW('%s') failed: %08X", new_wpath.c_str(), GetLastError());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!MoveFileFromAppW(old_wpath.c_str(), new_wpath.c_str()))
|
|
||||||
{
|
|
||||||
Log_ErrorPrintf("MoveFileFromAppW('%s', '%s') failed: %08X", old_path, new_path, GetLastError());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1556,10 +1317,8 @@ std::string FileSystem::GetProgramPath()
|
||||||
|
|
||||||
// Fall back to the main module if this fails.
|
// Fall back to the main module if this fails.
|
||||||
HMODULE module = nullptr;
|
HMODULE module = nullptr;
|
||||||
#ifndef _UWP
|
|
||||||
GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
|
GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
|
||||||
reinterpret_cast<LPCWSTR>(&GetProgramPath), &module);
|
reinterpret_cast<LPCWSTR>(&GetProgramPath), &module);
|
||||||
#endif
|
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
|
|
|
@ -69,11 +69,7 @@ namespace Vulkan
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM | WINAPI_PARTITION_GAMES)
|
|
||||||
vulkan_module = LoadLibraryA("vulkan-1.dll");
|
vulkan_module = LoadLibraryA("vulkan-1.dll");
|
||||||
#else
|
|
||||||
vulkan_module = NULL;
|
|
||||||
#endif
|
|
||||||
if (!vulkan_module)
|
if (!vulkan_module)
|
||||||
{
|
{
|
||||||
std::fprintf(stderr, "Failed to load vulkan-1.dll\n");
|
std::fprintf(stderr, "Failed to load vulkan-1.dll\n");
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#include "WindowInfo.h"
|
#include "WindowInfo.h"
|
||||||
#include "Console.h"
|
#include "Console.h"
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(_UWP)
|
#if defined(_WIN32)
|
||||||
|
|
||||||
#include "RedtapeWindows.h"
|
#include "RedtapeWindows.h"
|
||||||
#include <dwmapi.h>
|
#include <dwmapi.h>
|
||||||
|
|
Loading…
Reference in New Issue