mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-14 22:29:15 +01:00
Handle non-ASCII characters properly in paths
This commit is contained in:
parent
7bf02a1925
commit
bb85a4caa8
@ -27,7 +27,7 @@ namespace dxvk {
|
|||||||
const std::string dumpPath = env::getEnvVar("DXVK_SHADER_DUMP_PATH");
|
const std::string dumpPath = env::getEnvVar("DXVK_SHADER_DUMP_PATH");
|
||||||
|
|
||||||
if (dumpPath.size() != 0) {
|
if (dumpPath.size() != 0) {
|
||||||
reader.store(std::ofstream(str::format(dumpPath, "/", name, ".dxbc"),
|
reader.store(std::ofstream(str::tows(str::format(dumpPath, "/", name, ".dxbc").c_str()).c_str(),
|
||||||
std::ios_base::binary | std::ios_base::trunc));
|
std::ios_base::binary | std::ios_base::trunc));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
if (dumpPath.size() != 0) {
|
if (dumpPath.size() != 0) {
|
||||||
std::ofstream dumpStream(
|
std::ofstream dumpStream(
|
||||||
str::format(dumpPath, "/", name, ".spv"),
|
str::tows(str::format(dumpPath, "/", name, ".spv").c_str()).c_str(),
|
||||||
std::ios_base::binary | std::ios_base::trunc);
|
std::ios_base::binary | std::ios_base::trunc);
|
||||||
|
|
||||||
m_shader->dump(dumpStream);
|
m_shader->dump(dumpStream);
|
||||||
|
@ -2340,7 +2340,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
if (dumpPath.size() != 0) {
|
if (dumpPath.size() != 0) {
|
||||||
std::ofstream dumpStream(
|
std::ofstream dumpStream(
|
||||||
str::format(dumpPath, "/", Name, ".spv"),
|
str::tows(str::format(dumpPath, "/", Name, ".spv").c_str()).c_str(),
|
||||||
std::ios_base::binary | std::ios_base::trunc);
|
std::ios_base::binary | std::ios_base::trunc);
|
||||||
|
|
||||||
m_shader->dump(dumpStream);
|
m_shader->dump(dumpStream);
|
||||||
@ -2460,4 +2460,4 @@ namespace dxvk {
|
|||||||
|
|
||||||
DxsoIsgn g_ffIsgn = CreateFixedFunctionIsgn();
|
DxsoIsgn g_ffIsgn = CreateFixedFunctionIsgn();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ namespace dxvk {
|
|||||||
DxsoReader reader(
|
DxsoReader reader(
|
||||||
reinterpret_cast<const char*>(pShaderBytecode));
|
reinterpret_cast<const char*>(pShaderBytecode));
|
||||||
|
|
||||||
reader.store(std::ofstream(str::format(dumpPath, "/", name, ".dxso"),
|
reader.store(std::ofstream(str::tows(str::format(dumpPath, "/", name, ".dxso").c_str()).c_str(),
|
||||||
std::ios_base::binary | std::ios_base::trunc), bytecodeLength);
|
std::ios_base::binary | std::ios_base::trunc), bytecodeLength);
|
||||||
|
|
||||||
char comment[2048];
|
char comment[2048];
|
||||||
@ -44,7 +44,7 @@ namespace dxvk {
|
|||||||
&blob);
|
&blob);
|
||||||
|
|
||||||
if (SUCCEEDED(hr)) {
|
if (SUCCEEDED(hr)) {
|
||||||
std::ofstream disassembledOut(str::format(dumpPath, "/", name, ".dxso.dis"), std::ios_base::binary | std::ios_base::trunc);
|
std::ofstream disassembledOut(str::tows(str::format(dumpPath, "/", name, ".dxso.dis").c_str()).c_str(), std::ios_base::binary | std::ios_base::trunc);
|
||||||
disassembledOut.write(
|
disassembledOut.write(
|
||||||
reinterpret_cast<const char*>(blob->GetBufferPointer()),
|
reinterpret_cast<const char*>(blob->GetBufferPointer()),
|
||||||
blob->GetBufferSize());
|
blob->GetBufferSize());
|
||||||
@ -83,7 +83,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
if (dumpPath.size() != 0) {
|
if (dumpPath.size() != 0) {
|
||||||
std::ofstream dumpStream(
|
std::ofstream dumpStream(
|
||||||
str::format(dumpPath, "/", name, ".spv"),
|
str::tows(str::format(dumpPath, "/", name, ".spv").c_str()).c_str(),
|
||||||
std::ios_base::binary | std::ios_base::trunc);
|
std::ios_base::binary | std::ios_base::trunc);
|
||||||
|
|
||||||
m_shaders[0]->dump(dumpStream);
|
m_shaders[0]->dump(dumpStream);
|
||||||
@ -147,4 +147,4 @@ namespace dxvk {
|
|||||||
return commonShader;
|
return commonShader;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -128,12 +128,12 @@ namespace dxvk {
|
|||||||
Logger::warn("DXVK: Creating new state cache file");
|
Logger::warn("DXVK: Creating new state cache file");
|
||||||
|
|
||||||
// Start with an empty file
|
// Start with an empty file
|
||||||
std::ofstream file(getCacheFileName(),
|
std::ofstream file(getCacheFileName().c_str(),
|
||||||
std::ios_base::binary |
|
std::ios_base::binary |
|
||||||
std::ios_base::trunc);
|
std::ios_base::trunc);
|
||||||
|
|
||||||
if (!file && env::createDirectory(getCacheDir())) {
|
if (!file && env::createDirectory(getCacheDir())) {
|
||||||
file = std::ofstream(getCacheFileName(),
|
file = std::ofstream(getCacheFileName().c_str(),
|
||||||
std::ios_base::binary |
|
std::ios_base::binary |
|
||||||
std::ios_base::trunc);
|
std::ios_base::trunc);
|
||||||
}
|
}
|
||||||
@ -349,7 +349,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
bool DxvkStateCache::readCacheFile() {
|
bool DxvkStateCache::readCacheFile() {
|
||||||
// Open state file and just fail if it doesn't exist
|
// Open state file and just fail if it doesn't exist
|
||||||
std::ifstream ifile(getCacheFileName(), std::ios_base::binary);
|
std::ifstream ifile(getCacheFileName().c_str(), std::ios_base::binary);
|
||||||
|
|
||||||
if (!ifile) {
|
if (!ifile) {
|
||||||
Logger::warn("DXVK: No state cache file found");
|
Logger::warn("DXVK: No state cache file found");
|
||||||
@ -935,7 +935,7 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!file) {
|
if (!file) {
|
||||||
file = std::ofstream(getCacheFileName(),
|
file = std::ofstream(getCacheFileName().c_str(),
|
||||||
std::ios_base::binary |
|
std::ios_base::binary |
|
||||||
std::ios_base::app);
|
std::ios_base::app);
|
||||||
}
|
}
|
||||||
@ -945,7 +945,7 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string DxvkStateCache::getCacheFileName() const {
|
std::wstring DxvkStateCache::getCacheFileName() const {
|
||||||
std::string path = getCacheDir();
|
std::string path = getCacheDir();
|
||||||
|
|
||||||
if (!path.empty() && *path.rbegin() != '/')
|
if (!path.empty() && *path.rbegin() != '/')
|
||||||
@ -958,7 +958,7 @@ namespace dxvk {
|
|||||||
exeName.erase(extp);
|
exeName.erase(extp);
|
||||||
|
|
||||||
path += exeName + ".dxvk-cache";
|
path += exeName + ".dxvk-cache";
|
||||||
return path;
|
return str::tows(path.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
void writerFunc();
|
void writerFunc();
|
||||||
|
|
||||||
std::string getCacheFileName() const;
|
std::wstring getCacheFileName() const;
|
||||||
|
|
||||||
std::string getCacheDir() const;
|
std::string getCacheDir() const;
|
||||||
|
|
||||||
@ -191,4 +191,4 @@ namespace dxvk {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -593,7 +593,7 @@ namespace dxvk {
|
|||||||
filePath = "dxvk.conf";
|
filePath = "dxvk.conf";
|
||||||
|
|
||||||
// Open the file if it exists
|
// Open the file if it exists
|
||||||
std::ifstream stream(filePath);
|
std::ifstream stream(str::tows(filePath.c_str()).c_str());
|
||||||
|
|
||||||
if (!stream)
|
if (!stream)
|
||||||
return config;
|
return config;
|
||||||
|
@ -10,7 +10,7 @@ namespace dxvk {
|
|||||||
auto path = getFileName(file_name);
|
auto path = getFileName(file_name);
|
||||||
|
|
||||||
if (!path.empty())
|
if (!path.empty())
|
||||||
m_fileStream = std::ofstream(path);
|
m_fileStream = std::ofstream(str::tows(path.c_str()).c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,10 +5,13 @@
|
|||||||
namespace dxvk::env {
|
namespace dxvk::env {
|
||||||
|
|
||||||
std::string getEnvVar(const char* name) {
|
std::string getEnvVar(const char* name) {
|
||||||
char* result = std::getenv(name);
|
std::vector<WCHAR> result;
|
||||||
return (result)
|
result.resize(MAX_PATH + 1);
|
||||||
? result
|
|
||||||
: "";
|
DWORD len = ::GetEnvironmentVariableW(str::tows(name).c_str(), result.data(), MAX_PATH);
|
||||||
|
result.resize(len);
|
||||||
|
|
||||||
|
return str::fromws(result.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,4 +24,20 @@ namespace dxvk::str {
|
|||||||
wcs, wcsLen);
|
wcs, wcsLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::wstring tows(const char* mbs) {
|
||||||
|
size_t len = ::MultiByteToWideChar(CP_UTF8,
|
||||||
|
0, mbs, -1, nullptr, 0);
|
||||||
|
|
||||||
|
if (len <= 1)
|
||||||
|
return L"";
|
||||||
|
|
||||||
|
len -= 1;
|
||||||
|
|
||||||
|
std::wstring result;
|
||||||
|
result.resize(len);
|
||||||
|
::MultiByteToWideChar(CP_UTF8, 0, mbs, -1,
|
||||||
|
&result.at(0), len);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,8 @@ namespace dxvk::str {
|
|||||||
void tows(const char* mbs, WCHAR (&wcs)[N]) {
|
void tows(const char* mbs, WCHAR (&wcs)[N]) {
|
||||||
return tows(mbs, wcs, N);
|
return tows(mbs, wcs, N);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::wstring tows(const char* mbs);
|
||||||
|
|
||||||
inline void format1(std::stringstream&) { }
|
inline void format1(std::stringstream&) { }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user