Skip to content

Commit

Permalink
Merge pull request #2329 from digit-google/fix-mingw-compilation
Browse files Browse the repository at this point in the history
Fix Mingw cross-compilation.
  • Loading branch information
jhasse authored Sep 25, 2023
2 parents 08cfea5 + eddafdd commit f64267f
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/disk_interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
#include <sys/types.h>

#ifdef _WIN32
#include <sstream>
#include <windows.h>
#include <direct.h> // _mkdir
#include <atlcore.h>
#include <windows.h>

#include <sstream>
#else
#include <unistd.h>
#endif
Expand Down Expand Up @@ -162,10 +162,16 @@ RealDiskInterface::RealDiskInterface()
#ifdef _WIN32
: use_cache_(false), long_paths_enabled_(false) {
setlocale(LC_ALL, "");
IFDYNAMICGETCACHEDFUNCTIONTYPEDEF(L"ntdll", BOOLEAN(WINAPI*)(),
"RtlAreLongPathsEnabled",
RtlAreLongPathsEnabled) {
long_paths_enabled_ = RtlAreLongPathsEnabled();

// Probe ntdll.dll for RtlAreLongPathsEnabled, and call it if it exists.
HINSTANCE ntdll_lib = ::GetModuleHandleW(L"ntdll");
if (ntdll_lib) {
typedef BOOLEAN(WINAPI FunctionType)();
auto* func_ptr = reinterpret_cast<FunctionType*>(
::GetProcAddress(ntdll_lib, "RtlAreLongPathsEnabled"));
if (func_ptr) {
long_paths_enabled_ = (*func_ptr)();
}
}
}
#else
Expand Down

0 comments on commit f64267f

Please sign in to comment.