os: use extended-length paths on Windows when possible
Windows has a limit of 260 characters on normal paths, but it's possible to use longer paths by using "extended-length paths" that begin with `\\?\`. This commit attempts to transparently convert an absolute path to an extended-length path, following the subtly different rules those paths require. It does not attempt to handle relative paths, which continue to be passed to the operating system unmodified. This adds a new test, TestLongPath, to the os package. This test makes sure that it is possible to write a path at least 400 characters long and runs on every platform. It also tests symlinks and hardlinks, though symlinks are not testable with our builder configuration. HasLink is moved to internal/testenv so it can be used by multiple tests. https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx has Microsoft's documentation on extended-length paths. Fixes #3358. Fixes #10577. Fixes #17500. Change-Id: I4ff6bb2ef9c9a4468d383d98379f65cf9c448218 Reviewed-on: https://go-review.googlesource.com/32451 Run-TryBot: Quentin Smith <quentin@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
Showing
src/os/path_windows_test.go
0 → 100644
Please register or sign in to comment