diff options
| author | George Adams <georgeadams1995@gmail.com> | 2024-11-19 10:05:27 +0000 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2024-11-19 17:26:40 +0000 |
| commit | 5deea4c2425fd8aa6dee642c63a1bc43e090d04b (patch) | |
| tree | 081b394780d619b01d8b02aeea61833ed84530fc /src/os/path_windows.go | |
| parent | 405a0c4ae86fe2761118ee6d1d59e59daf9b50cd (diff) | |
| download | go-5deea4c2425fd8aa6dee642c63a1bc43e090d04b.tar.xz | |
Revert "os: check for valid Windows path when creating files"
This reverts commit CL 618496.
Reason for revert: https://github.com/golang/go/issues/54040#issuecomment-2485151973
Change-Id: I3bf27f7fdd475a005cb6aa190994153504e96fb5
Reviewed-on: https://go-review.googlesource.com/c/go/+/629595
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Diffstat (limited to 'src/os/path_windows.go')
| -rw-r--r-- | src/os/path_windows.go | 29 |
1 files changed, 0 insertions, 29 deletions
diff --git a/src/os/path_windows.go b/src/os/path_windows.go index d72649be86..f585aa5ee6 100644 --- a/src/os/path_windows.go +++ b/src/os/path_windows.go @@ -6,7 +6,6 @@ package os import ( "internal/filepathlite" - "internal/stringslite" "internal/syscall/windows" "syscall" ) @@ -151,31 +150,3 @@ func addExtendedPrefix(path string) string { copy(buf, prefix) return syscall.UTF16ToString(buf) } - -// validatePathForCreate checks if a given path is valid for creation on a Windows system. -// It returns true if the path is considered valid, and false otherwise. -// The function performs the following checks: -// 1. If the path is empty, it is considered valid. -// 2. If the path starts with `\\?\` or \??\, it is considered valid without further checks. -// 3. Otherwise, a path ending with a space or . is invalid. -func validatePathForCreate(path string) bool { - // Check if the path is empty. - if len(path) == 0 { - return true - } - // Paths starting with \\?\ should be considered valid without further checks. - if stringslite.HasPrefix(path, `\\?\`) || stringslite.HasPrefix(path, `\??\`) { - return true - } - // Get the base name of the path to check only the last component. - base := filepathlite.Base(path) - // Check if the last character of the base name is a space or period, which is invalid. - switch base[len(base)-1] { - case ' ': - return false - case '.': - return base == "." || base == ".." - default: - return true - } -} |
