mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-11 07:11:54 +00:00
- Consider 'Program Files' a read only location without actually checking.
Due to virtualization the actual check may not produce correct results, plus writing there is bad style anyway.
This commit is contained in:
parent
8c715d48cd
commit
23a2ccec2b
1 changed files with 29 additions and 9 deletions
|
@ -74,16 +74,36 @@ bool UseKnownFolders()
|
|||
{
|
||||
return !iswritable;
|
||||
}
|
||||
std::wstring testpath = progdir.WideString() + L"writest";
|
||||
file = CreateFile(testpath.c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL,
|
||||
CREATE_ALWAYS,
|
||||
FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE, NULL);
|
||||
if (file != INVALID_HANDLE_VALUE)
|
||||
// Consider 'Program Files' read only without actually checking.
|
||||
bool found = false;
|
||||
for (auto p : { L"ProgramFiles", L"ProgramFiles(x86)" })
|
||||
{
|
||||
CloseHandle(file);
|
||||
if (!batchrun) Printf("Using program directory for storage\n");
|
||||
iswritable = true;
|
||||
return false;
|
||||
wchar_t buffer1[256];
|
||||
if (GetEnvironmentVariable(p, buffer1, 256))
|
||||
{
|
||||
FString envpath(buffer1);
|
||||
FixPathSeperator(envpath);
|
||||
if (progdir.MakeLower().IndexOf(envpath.MakeLower()) == 0)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
std::wstring testpath = progdir.WideString() + L"writest";
|
||||
file = CreateFile(testpath.c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL,
|
||||
CREATE_ALWAYS,
|
||||
FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE, NULL);
|
||||
if (file != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
CloseHandle(file);
|
||||
if (!batchrun) Printf("Using program directory for storage\n");
|
||||
iswritable = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!batchrun) Printf("Using known folders for storage\n");
|
||||
iswritable = false;
|
||||
|
|
Loading…
Reference in a new issue