mirror of
https://github.com/golang/go
synced 2024-11-27 14:59:01 +00:00
43d90c6a14
Add os.Root, a type which represents a directory and permits performing file operations within that directory. For #67002 Change-Id: I863f4f1bc320a89b1125ae4237761f3e9320a901 Reviewed-on: https://go-review.googlesource.com/c/go/+/612136 Reviewed-by: 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>
17 lines
602 B
Markdown
17 lines
602 B
Markdown
### Directory-limited filesystem access
|
|
|
|
<!-- go.dev/issue/67002 -->
|
|
The new [os.Root] type provides the ability to perform filesystem
|
|
operations within a specific directory.
|
|
|
|
The [os.OpenRoot] function opens a directory and returns an [os.Root].
|
|
Methods on [os.Root] operate within the directory and do not permit
|
|
paths that refer to locations outside the directory, including
|
|
ones that follow symbolic links out of the directory.
|
|
|
|
- [os.Root.Open] opens a file for reading.
|
|
- [os.Root.Create] creates a file.
|
|
- [os.Root.OpenFile] is the generalized open call.
|
|
- [os.Root.Mkdir] creates a directory.
|
|
|