aboutsummaryrefslogtreecommitdiff
path: root/src/os/path.go
AgeCommit message (Collapse)Author
2024-04-30os: use filepathlite.VolumeNameqmuntal
It is better to have a single implementation of VolumeName, which is quite tricky to get right on Windows. Change-Id: Ibba82dd71fe10b594cb6f782582430aa422e7078 Reviewed-on: https://go-review.googlesource.com/c/go/+/582499 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com> Run-TryBot: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-02-26os: add available godoc linkcui fliter
Change-Id: I430c9a7c4936d7a8c8c787aa63de9a796d20fdf3 Reviewed-on: https://go-review.googlesource.com/c/go/+/539597 Reviewed-by: Carlos Amedee <carlos@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: shuang cui <imcusg@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-08-09os: make MkdirAll support volume namesqmuntal
MkdirAll fails to create directories under root paths using volume names (e.g. //?/Volume{GUID}/foo). This is because fixRootDirectory only handle extended length paths using drive letters (e.g. //?/C:/foo). This CL fixes that issue by also detecting volume names without path separator. Updates #22230 Fixes #39785 Change-Id: I813fdc0b968ce71a4297f69245b935558e6cd789 Reviewed-on: https://go-review.googlesource.com/c/go/+/517015 Run-TryBot: Quim Muntal <quimmuntal@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2020-10-20os: use keyed literals for PathErrorRuss Cox
Necessary to move PathError to io/fs. For #41190. Change-Id: I05e87675f38a22f0570d4366b751b6169f7a1b13 Reviewed-on: https://go-review.googlesource.com/c/go/+/243900 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-10-29os: return from TestRemoveAllWithMoreErrorThanReqSize when RemoveAll ↵Constantin Konstantinidis
succeeds on Windows Also remove unused test hook. Updates #35117 Change-Id: I6f05ba234fb09e4b44e77c1539c02d1aed49910a Reviewed-on: https://go-review.googlesource.com/c/go/+/204060 Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-04-10os: fix RemoveAll hangs on large directoryLE Manh Cuong
golang.org/cl/121255 added close and re-open the directory when looping, prevent us from missing some if previous iteration deleted files. The CL introdued a bug. If we can not delete all entries in one request, the looping never exits, causing RemoveAll hangs. To fix that, simply discard the entries if we can not delete all of them in one iteration, then continue reading entries and delete them. Also make sure removeall_at return first error it encounters. Fixes #29921 Change-Id: I8ec3a4c822d8d2d95d9f1ab71547879da395bc4a Reviewed-on: https://go-review.googlesource.com/c/go/+/171099 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-03-15os: consistently return PathError from RemoveAllBaokun Lee
Fixes #30491 Change-Id: If4070e5d39d8649643d7e90f6f3eb499642e25ab Reviewed-on: https://go-review.googlesource.com/c/go/+/164720 Run-TryBot: Baokun Lee <nototon@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2019-01-30os: restore RemoveAll docs by making a single copyIan Lance Taylor
Updates #29983 Change-Id: Ifdf8aa9c92e053374e301a4268d85e277c15f0b5 Reviewed-on: https://go-review.googlesource.com/c/160182 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-11-21os: prevent RemoveAll to remove "." on Plan 9David du Colombier
CL 150497 enabled TestRemoveAllDot on "noat" systems. However, this test is failing on Plan 9 because the rmdir system call allows to remove "." on Plan 9. This change prevents the "noat" implementation of RemoveAll to remove ".", so it remains consistent with the "at" implementation. Fixes #28903. Change-Id: Ifc8fe36bdd8053a4e416f0590663c844c97ce72a Reviewed-on: https://go-review.googlesource.com/c/150621 Run-TryBot: David du Colombier <0intro@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-10-31os: add support for long path names on unix RemoveAllOliver Stenbom
On unix systems, long enough path names will fail when performing syscalls like `Lstat`. The current RemoveAll uses several of these syscalls, and so will fail for long paths. This can be risky, as it can let users "hide" files from the system or otherwise make long enough paths for programs to fail. By using `Unlinkat` and `Openat` syscalls instead, RemoveAll is safer on unix systems. Initially implemented for linux, darwin, dragonfly, netbsd and openbsd. Not yet implemented on freebsd due to fstatat 64-bit inode compatibility issues. Fixes #27029 Co-authored-by: Giuseppe Capizzi <gcapizzi@pivotal.io> Co-authored-by: Julia Nedialkova <yulia.nedyalkova@sap.com> Change-Id: I978a6a4986878fe076d3c7af86e7927675624a96 GitHub-Last-Rev: 9235489c81b90c228210144b7c25b28a46bb80b7 GitHub-Pull-Request: golang/go#28494 Reviewed-on: https://go-review.googlesource.com/c/146020 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-10-30Revert "os: add support for long path names on unix RemoveAll"Katie Hockman
This reverts commit 85143d355493c6bba994d49ed154b4df8b78874b. Reason for revert: Breaking all Darwin and FreeBSD builds. Trybots did not pass for this. Change-Id: I5494e14ad5ab9cf6e1e225a25b2e8b38f3359d13 Reviewed-on: https://go-review.googlesource.com/c/145897 Reviewed-by: Katie Hockman <katie@golang.org> Run-TryBot: Katie Hockman <katie@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-10-30os: add support for long path names on unix RemoveAllOliver Stenbom
On unix systems, long enough path names will fail when performing syscalls like `Lstat`. The current RemoveAll uses several of these syscalls, and so will fail for long paths. This can be risky, as it can let users "hide" files from the system or otherwise make long enough paths for programs to fail. By using `Unlinkat` and `Openat` syscalls instead, RemoveAll is safer on unix systems. Initially implemented for linux, darwin, and several bsds. Fixes #27029 Co-authored-by: Giuseppe Capizzi <gcapizzi@pivotal.io> Co-authored-by: Julia Nedialkova <yulia.nedyalkova@sap.com> Change-Id: Id9fcdf4775962b021b7ff438dc51ee6d16bb5f56 GitHub-Last-Rev: b30a621fe359fa2acbb055445b54202b0c508167 GitHub-Pull-Request: golang/go#27871 Reviewed-on: https://go-review.googlesource.com/c/137442 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-27os: when looping in RemoveAll, close and re-open directoryIan Lance Taylor
On some systems removing files can cause a directory to be re-shuffled, so simply continuing to read files can cause us to miss some. Close and re-open the directory when looping, to avoid that. Read more files each time through the loop, to reduce the chance of having to re-open. Fixes #20841 Change-Id: I98a14774ca63786ad05ba5000cbdb01ad2884332 Reviewed-on: https://go-review.googlesource.com/121255 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-02-23path: use OS-specific function in MkdirAll, don't always keep trailing slashIan Lance Taylor
CL 86295 changed MkdirAll to always pass a trailing path separator to support extended-length paths on Windows. However, when Stat is called on an existing file followed by trailing slash, it will return a "not a directory" error, skipping the fast path at the beginning of MkdirAll. This change fixes MkdirAll to only pass the trailing path separator where required on Windows, by using an OS-specific function fixRootDirectory. Updates #23918 Change-Id: I23f84a20e65ccce556efa743d026d352b4812c34 Reviewed-on: https://go-review.googlesource.com/95255 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David du Colombier <0intro@gmail.com> Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2018-02-18os: make MkdirAll support path in extended-length formMansour Rahimi
Calling MkdirAll on paths in extended-length form (\\?\-prefixed) failed. MkdirAll calls itself recursively with parent directory of given path in its parameter. It finds parent directory by looking for delimiter in the path, and taking the left part. When path is in extended-length form, it finds empty path at the end. Here is a sample of path in extended-length form: \\?\c:\foo\bar This change fixes that by passing trailing path separator to MkdirAll (so it works for path like \\?\c:\). Fixes #22230 Change-Id: I363660b262588c5382ea829773d3b6005ab8df3c Reviewed-on: https://go-review.googlesource.com/86295 Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Run-TryBot: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-12-15os: mention the influence of umask in docsMatthijs Kooijman
Change-Id: Ia05fac3298334d6b44267ce02bffcd7bf8a54c72 Reviewed-on: https://go-review.googlesource.com/83775 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-11-06os: fix RemoveAll on large directories on Plan 9 and NaClDavid du Colombier
On Plan 9, some file servers, like ramfs, handle the read offset when reading directories. However, the offset isn't valid anymore after directory entries have been removed between successive calls to read. This issue happens when os.RemoveAll is called on a directory that doesn't fit on a single 9P response message. In this case, the first part of the directory is read, then directory entries are removed and the second read will be incomplete because the read offset won't be valid anymore. Consequently, the content of the directory will only be partially removed. We change RemoveAll to call fd.Seek(0, 0) before calling fd.Readdirnames, so the read offset will always be reset after removing the directory entries. After adding TestRemoveAllLarge, we noticed the same issue appears on NaCl and the same fix applies as well. Fixes #22572. Change-Id: Ifc76ea7ccaf0168c34dc8ec0f400dc04db1baf8f Reviewed-on: https://go-review.googlesource.com/75974 Run-TryBot: David du Colombier <0intro@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-02all: single space after period.Brad Fitzpatrick
The tree's pretty inconsistent about single space vs double space after a period in documentation. Make it consistently a single space, per earlier decisions. This means contributors won't be confused by misleading precedence. This CL doesn't use go/doc to parse. It only addresses // comments. It was generated with: $ perl -i -npe 's,^(\s*// .+[a-z]\.) +([A-Z]),$1 $2,' $(git grep -l -E '^\s*//(.+\.) +([A-Z])') $ go test go/doc -update Change-Id: Iccdb99c37c797ef1f804a94b22ba5ee4b500c4f7 Reviewed-on: https://go-review.googlesource.com/20022 Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Dave Day <djd@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2014-10-06os: recomment MkdirAllRuss Cox
The internal comments are not completely precise about what is going on, and they are causing confusion. Fixes #8283. LGTM=r R=r CC=golang-codereviews https://golang.org/cl/151460043
2014-09-23os: add a comment inside RemoveAllBrad Fitzpatrick
LGTM=r R=r CC=golang-codereviews https://golang.org/cl/149950043
2014-09-23os: fix another case where RemoveAll should return nilBrad Fitzpatrick
This hopefully fixes issue 8793. Fixes #8793 LGTM=iant R=rsc, iant CC=golang-codereviews https://golang.org/cl/150860046
2014-09-18os: avoid error result when dir is removed out from under RemoveAllRuss Cox
Fixes #7776. LGTM=bradfitz R=golang-codereviews, bradfitz CC=golang-codereviews, r https://golang.org/cl/145860043
2014-09-08build: move package sources from src/pkg to srcRuss Cox
Preparation was in CL 134570043. This CL contains only the effect of 'hg mv src/pkg/* src'. For more about the move, see golang.org/s/go14nopkg.