Skip to content

Commit 8509f69

Browse files
qmuntalneild
authored andcommitted
os: use filepathlite.FromSlash
Change-Id: Id15ebd9e97a8626e64665f6830a662e62432a619 Reviewed-on: https://go-review.googlesource.com/c/go/+/582500 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Damien Neil <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 5616ab6 commit 8509f69

File tree

2 files changed

+1
-23
lines changed

2 files changed

+1
-23
lines changed

src/os/file_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ func Link(oldname, newname string) error {
288288
// If there is an error, it will be of type *LinkError.
289289
func Symlink(oldname, newname string) error {
290290
// '/' does not work in link's content
291-
oldname = fromSlash(oldname)
291+
oldname = filepathlite.FromSlash(oldname)
292292

293293
// need the exact location of the oldname when it's relative to determine if it's a directory
294294
destpath := oldname

src/os/path_windows.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -45,28 +45,6 @@ func basename(name string) string {
4545
return name
4646
}
4747

48-
func fromSlash(path string) string {
49-
// Replace each '/' with '\\' if present
50-
var pathbuf []byte
51-
var lastSlash int
52-
for i, b := range path {
53-
if b == '/' {
54-
if pathbuf == nil {
55-
pathbuf = make([]byte, len(path))
56-
}
57-
copy(pathbuf[lastSlash:], path[lastSlash:i])
58-
pathbuf[i] = '\\'
59-
lastSlash = i + 1
60-
}
61-
}
62-
if pathbuf == nil {
63-
return path
64-
}
65-
66-
copy(pathbuf[lastSlash:], path[lastSlash:])
67-
return string(pathbuf)
68-
}
69-
7048
func dirname(path string) string {
7149
vol := filepathlite.VolumeName(path)
7250
i := len(path) - 1

0 commit comments

Comments
 (0)