Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly support for Windows long file paths through Unicode Win32 API calls. #2410

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Commits on May 7, 2024

  1. util.c: Add UTF8ToWin32Unicode() + Win32UnicodeToUTF8()

    UTF8ToWin32Unicode() converts an UTF-8 string into the
    corresponding Windows UCS-2 one, and will be used
    to call Unicode Win32 API directly, in order to
    properly support long file paths everywhere.
    
    Win32UnicodeToUTF8() does the opposite, and will
    generally be used to display such native Win32
    paths in error messages.
    digit-google committed May 7, 2024
    Configuration menu
    Copy the full SHA
    52ba96e View commit details
    Browse the repository at this point in the history
  2. Add SystemDiskInterface and NullDiskInterface classes.

    Add an intermediate DiskInterface derived class named
    SystemDiskInterface that performs real disk i/o without
    any intermediate caching.
    
    RealDiskInterface is now a derived class of
    SystemDiskInterface that adds a caching layer on
    Win32 only. Keeping the same name reduces the number
    of changes in this commit to the strict minimum.
    
    NullDiskInterface is provided to simplify custom
    DiskInterface implementations used in tests, in
    particular because new DiskInterface methods are
    going to be added in future commits, and adding
    the same method overrides NullDiskInterface will
    lower the changes to do in those implementations.
    digit-google committed May 7, 2024
    Configuration menu
    Copy the full SHA
    947c82f View commit details
    Browse the repository at this point in the history
  3. Remove Win32 ANSI calls from DiskInteface

    Ensure Win32 Unicode APIs are called when trying to
    perform real disk i/o. This is necessary to properly
    support long file paths on Windows.
    
    For example, FindFirstFileExW() used in RealDiskInterface
    has not MAC_PATH restriction, though FindFirstFileExA()
    still does, even when long path support is enabled
    on the host machine.
    
    Note that generally speaking, it is unknown whether Windows
    CRT functions, such as fopen(), rename(), _unlink(), always
    properly support long file paths (it may very well depend
    on the version of MSVCRT linked to the executable), so
    it is better to err on the side of caution and always
    try to use the wide-char versions of these functions,
    when available, or to fall back to Unicode Win32 API
    functions otherwise.
    
    This applies here and the commits following this one
    in the same pull request.
    digit-google committed May 7, 2024
    Configuration menu
    Copy the full SHA
    4290828 View commit details
    Browse the repository at this point in the history
  4. util.c: ReadFile(): support Win32 long paths.

    Use CreateFileW() to ensure proper long path support on Win32.
    digit-google committed May 7, 2024
    Configuration menu
    Copy the full SHA
    7874b1e View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    bb6fc34 View commit details
    Browse the repository at this point in the history
  6. minidump-win32.cc: Use Win32 Unicode APIs.

    + Allow it to compile with cross-toolchains like Mingw.
    digit-google committed May 7, 2024
    Configuration menu
    Copy the full SHA
    c43020a View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    eebdcc9 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    f78927e View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    7c40cef View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    5771d8a View commit details
    Browse the repository at this point in the history
  11. BuildLog: Use DiskInterface instance.

    Make the BuildLog class take a DiskInterface
    reference in its constructor, to ensure that all
    i/o operations use the same interface.
    
    + Adjust call sites accordingly. For tests, always
      use a SystemDiskInterface instead of the VirtualFileSystem
      instance when the latter is available, as this is
      exactly what the previous code was doing.
    digit-google committed May 7, 2024
    Configuration menu
    Copy the full SHA
    5996e69 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    e4085e5 View commit details
    Browse the repository at this point in the history