mirror of
https://github.com/thunderbrewhq/bc.git
synced 2025-12-12 01:52:30 +00:00
fix(file): aggressively turn off macros that mess with Win32 filestack
This commit is contained in:
parent
12b4a4f7b4
commit
48d1a3c0b0
1 changed files with 5 additions and 11 deletions
|
|
@ -15,6 +15,8 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <sddl.h>
|
#include <sddl.h>
|
||||||
|
|
||||||
|
#include "bc/system/file/win/Support.hpp"
|
||||||
|
|
||||||
#define PATH(name) Blizzard::String::QuickNativePath<300UL>(name).ToString()
|
#define PATH(name) Blizzard::String::QuickNativePath<300UL>(name).ToString()
|
||||||
|
|
||||||
#define MAKEU64(high, low) static_cast<uint64_t>(high) << 32ULL | static_cast<uint64_t>(low)
|
#define MAKEU64(high, low) static_cast<uint64_t>(high) << 32ULL | static_cast<uint64_t>(low)
|
||||||
|
|
@ -473,13 +475,7 @@ bool (MakeAbsolutePath)(FileParms* parms) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// avoid clobbering
|
|
||||||
// System_File::Stacked::CreateDirectory
|
|
||||||
// into
|
|
||||||
// System_File::Stacked::CreateDirectoryA
|
|
||||||
#undef CreateDirectory
|
|
||||||
bool (CreateDirectory)(FileParms* parms) {
|
bool (CreateDirectory)(FileParms* parms) {
|
||||||
#define CreateDirectory CreateDirectoryA
|
|
||||||
if (!parms->name) {
|
if (!parms->name) {
|
||||||
BC_FILE_SET_ERROR(8);
|
BC_FILE_SET_ERROR(8);
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -521,7 +517,7 @@ bool (CreateDirectory)(FileParms* parms) {
|
||||||
|
|
||||||
Blizzard::String::QuickNativePath<300UL> directorypath(leadingpath);
|
Blizzard::String::QuickNativePath<300UL> directorypath(leadingpath);
|
||||||
|
|
||||||
if (::CreateDirectory(directorypath.ToString(), parms->set_acl ? &security_attr : nullptr)) {
|
if (::CreateDirectoryA(directorypath.ToString(), parms->set_acl ? &security_attr : nullptr)) {
|
||||||
if (*s == '\0') {
|
if (*s == '\0') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -547,7 +543,7 @@ bool (CreateDirectory)(FileParms* parms) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!::CreateDirectory(PATH(path), parms->set_acl ? &security_attr : nullptr)) {
|
if (!::CreateDirectoryA(PATH(path), parms->set_acl ? &security_attr : nullptr)) {
|
||||||
auto last_err = ::GetLastError();
|
auto last_err = ::GetLastError();
|
||||||
bool result = last_err == ERROR_ALREADY_EXISTS || last_err == ERROR_ACCESS_DENIED;
|
bool result = last_err == ERROR_ALREADY_EXISTS || last_err == ERROR_ACCESS_DENIED;
|
||||||
if (path != pathbuffer) {
|
if (path != pathbuffer) {
|
||||||
|
|
@ -696,9 +692,7 @@ bool (Open)(FileParms* parms) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef RemoveDirectory
|
|
||||||
bool (RemoveDirectory)(FileParms* parms) {
|
bool (RemoveDirectory)(FileParms* parms) {
|
||||||
#define RemoveDirectory RemoveDirectoryA
|
|
||||||
if (parms->recurse) {
|
if (parms->recurse) {
|
||||||
return Blizzard::File::RemoveDirectoryAndContents(parms->name, false);
|
return Blizzard::File::RemoveDirectoryAndContents(parms->name, false);
|
||||||
}
|
}
|
||||||
|
|
@ -712,7 +706,7 @@ bool (RemoveDirectory)(FileParms* parms) {
|
||||||
auto name = namesize > 260 ? reinterpret_cast<char*>(Blizzard::Memory::Allocate(namesize)) : namebuffer;
|
auto name = namesize > 260 ? reinterpret_cast<char*>(Blizzard::Memory::Allocate(namesize)) : namebuffer;
|
||||||
Blizzard::String::MakeBackslashPath(parms->name, name, 260);
|
Blizzard::String::MakeBackslashPath(parms->name, name, 260);
|
||||||
|
|
||||||
auto removed = ::RemoveDirectory(PATH(name));
|
auto removed = ::RemoveDirectoryA(PATH(name));
|
||||||
|
|
||||||
if (name != namebuffer) {
|
if (name != namebuffer) {
|
||||||
Blizzard::Memory::Free(name);
|
Blizzard::Memory::Free(name);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue