feat(vfs): define the vfs.FS contract, sentinels, PathOps and ReadOnly wrapper (2.0)
Types and interfaces from design §2.1: FS, File, FileInfo, Caps, VolumeID, RenameMode, CreateMode, PathOps (posix and native), Location.Same, the optional Trasher/BirthTimer/Execer interfaces and ReadOnly(fs). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
945ae80c73
commit
2db51e9385
7 changed files with 565 additions and 0 deletions
28
internal/vfs/location.go
Normal file
28
internal/vfs/location.go
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
package vfs
|
||||
|
||||
// Location is "where a panel stands / where an operation writes".
|
||||
type Location struct {
|
||||
FS FS
|
||||
Path string
|
||||
}
|
||||
|
||||
// Same reports whether both locations name the same path on the same volume
|
||||
// (lexically: equal VolumeID and equal cleaned paths). It does not resolve
|
||||
// symlinks; use SameFile or Within for identity.
|
||||
func (l Location) Same(o Location) bool {
|
||||
if l.FS == nil || o.FS == nil {
|
||||
return l.FS == nil && o.FS == nil && l.Path == o.Path
|
||||
}
|
||||
if l.FS.Volume() != o.FS.Volume() {
|
||||
return false
|
||||
}
|
||||
return l.FS.Paths().Clean(l.Path) == o.FS.Paths().Clean(o.Path)
|
||||
}
|
||||
|
||||
// String renders "label:path" for logs and messages.
|
||||
func (l Location) String() string {
|
||||
if l.FS == nil {
|
||||
return l.Path
|
||||
}
|
||||
return l.FS.Label() + ":" + l.Path
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue