vcom/internal/vfs/location.go
vrubelroman 2db51e9385 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>
2026-10-31 23:21:41 +03:00

28 lines
753 B
Go

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
}