]> Cypherpunks repositories - gostls13.git/commit
io/fs: add ReadLinkFS interface
authorRoxy Light <roxy@zombiezen.com>
Tue, 16 Jul 2024 17:21:30 +0000 (10:21 -0700)
committerCherry Mui <cherryyz@google.com>
Mon, 3 Feb 2025 16:38:43 +0000 (08:38 -0800)
commitf7b8dd9033663944e3b563afaeb55dace4c060fc
treeecb239b026d072c4a8e8cb4a6307fe4079074bda
parent9896da303a74c7af02f711fbb49ac08e4ef3590b
io/fs: add ReadLinkFS interface

Added implementations for *io/fs.subFS, os.DirFS, and testing/fstest.MapFS.
Amended testing/fstest.TestFS to check behavior.

Addressed TODOs in archive/tar and os.CopyFS around symbolic links.

I am deliberately not changing archive/zip in this CL,
since it currently does not resolve symlinks
as part of its filesystem implementation.
I am unsure of the compatibility restrictions on doing so,
so figured it would be better to address independently.

testing/fstest.MapFS now includes resolution of symlinks,
with MapFile.Data storing the symlink data.
The behavior change there seemed less intrusive,
especially given its intended usage in tests,
and it is especially helpful in testing the io/fs function implementations.

Fixes #49580

Change-Id: I58ec6915e8cc97341cdbfd9c24c67d1b60139447
Reviewed-on: https://go-review.googlesource.com/c/go/+/385534
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Funda Secgin <fundasecgin33@gmail.com>
19 files changed:
api/next/49580.txt [new file with mode: 0644]
doc/next/6-stdlib/99-minor/archive/tar/49580.md [new file with mode: 0644]
doc/next/6-stdlib/99-minor/io/fs/49580.md [new file with mode: 0644]
doc/next/6-stdlib/99-minor/os/49580.md [new file with mode: 0644]
doc/next/6-stdlib/99-minor/testing/fstest/49580.md [new file with mode: 0644]
src/archive/tar/writer.go
src/archive/tar/writer_test.go
src/io/fs/readlink.go [new file with mode: 0644]
src/io/fs/readlink_test.go [new file with mode: 0644]
src/io/fs/sub.go
src/io/fs/walk_test.go
src/os/dir.go
src/os/file.go
src/os/file_test.go [new file with mode: 0644]
src/os/os_test.go
src/testing/fstest/mapfs.go
src/testing/fstest/mapfs_test.go
src/testing/fstest/testfs.go
src/testing/fstest/testfs_test.go