When creating a file system representation from the path, we need to
strip the leading `/` which is added for the RFC representation of the
Windows path. Without this, the C runtime will fail with an invalid
argument error. Unfortunately this regresses the test suite by causing a
hang.
We would previously conditionally call `GetFullPathNameW` and do string
manipulations for normalising the path. Instead, always call
`GetFullPathNameW` to normalise the path as per Windows' rules. This
more importantly will collapse runs of the arc separator, which is
crucial when using extended paths as the NT path form must always use
the normalised paths or the access will fail.
The returned value in the success case does not account for the
terminating nul character, resulting in the value being 1 less than the
allocation required. This was causing a spurious failure and thus unable
to compute the location of the process.
This helper allows us to convert paths to the NT path representation.
The NT Path representation is important for internal usage as it allows
us to bypass the `MAX_PATH` (261) limit for Win32 APIs. In order to do
this, we simply escape the string with the NT prefix (`\\?\`) which
requires that the path is normalised (uses `\` rather than `/`) and
generally should be an absolute path. Using the NT path allows us to use
the fully supported 32k character path length of the NT kernel.
Co-authored-by: Alexander Smarus <bender@readdle.com>
Co-authored-by: Jeremy Schonfeld <1004103+jmschonfeld@users.noreply.github.com>
* Use smaller buffer for file system representation
* Reword scalars -> code-units
Co-authored-by: Karl <5254025+karwa@users.noreply.github.com>
---------
Co-authored-by: Karl <5254025+karwa@users.noreply.github.com>