lib/file: use builtin MkdirAll with go1.22 instead of our own custom version for windows

Starting with go1.22 the standard os.MkdirAll has improved its handling of volume names,
and as part of that it now stops recursing into parent directory if it is a volume name
(see: cd589c8a73).
This is similar to what was our main change and reason for creating a custom version. When
building with go1.22 or newer we can therefore stop using our custom version, with the
advantage that we automatically get current and future relevant improvements from golang.
To support building with go1.21 the existing custom version is still kept, and therefore
also our wrapper function file.MkdirAll - but it now just calls os.MkdirAll with go1.22
or newer on Windows.

See #5401, #6420 and acf1e2df84 for details about the
creation of our custom version of MkdirAll.
This commit is contained in:
albertony
2024-09-02 10:59:23 +02:00
parent 906aef91fa
commit 711478554e
4 changed files with 126 additions and 4 deletions

View File

@@ -1,10 +1,10 @@
//go:build !windows
//go:build !windows || go1.22
package file
import "os"
// MkdirAll just calls os.MkdirAll on non-Windows.
// MkdirAll just calls os.MkdirAll on non-Windows and with go1.22 or newer on Windows
func MkdirAll(path string, perm os.FileMode) error {
return os.MkdirAll(path, perm)
}