Documentation ¶
Overview ¶
Package path provides tools for parsing and printing file names. File names always start with a user name in mail-address form, followed by a slash and a possibly empty path name that follows. Thus the root of user@google.com's name space is "user@google.com/". But Parse also allows "user@google.com" to refer to the user's root directory.
Index ¶
- func Clean(path upspin.PathName) upspin.PathName
- func DropPath(pathName upspin.PathName, n int) upspin.PathName
- func FirstPath(pathName upspin.PathName, n int) upspin.PathName
- func Join(path upspin.PathName, elems ...string) upspin.PathName
- type Parsed
- func (p Parsed) Compare(q Parsed) int
- func (p Parsed) Drop(n int) Parsed
- func (p Parsed) Elem(n int) string
- func (p Parsed) Equal(q Parsed) bool
- func (p Parsed) FilePath() string
- func (p Parsed) First(n int) Parsed
- func (p Parsed) HasPrefix(root Parsed) bool
- func (p Parsed) IsRoot() bool
- func (p *Parsed) MarshalJSON() ([]byte, error)
- func (p Parsed) NElem() int
- func (p Parsed) Path() upspin.PathName
- func (p Parsed) String() string
- func (p *Parsed) UnmarshalJSON(data []byte) error
- func (p Parsed) User() upspin.UserName
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DropPath ¶
DropPath returns the path name with the last n elements dropped. It "cleans" the argument first, using the Clean function, which means that if the path is malformed or contains dot-dot (..) elements the result may be unexpected. The result has also been "cleaned" by the Clean function.
func FirstPath ¶
FirstPath returns the path name with the first n elements dropped. It "cleans" the argument first, using the Clean function, which means that if the path is malformed or contains dot-dot (..) elements the result may be unexpected. The result has also been "cleaned" by the Clean function.
func Join ¶
Join appends any number of path elements onto a (possibly empty) Upspin path, adding a separating slash if necessary. All empty strings are ignored. The result, if non-empty, is passed through Clean. There is no guarantee that the resulting path is a valid Upspin path. This differs from path.Join in that it requires a first argument of type upspin.PathName.
Types ¶
type Parsed ¶
type Parsed struct {
// contains filtered or unexported fields
}
Parsed represents a successfully parsed path name.
func Parse ¶
Parse parses a full file name, including the user, validates it, and returns its parsed form. If the name is a user root directory, the trailing slash is optional. The name is 'cleaned' (see the Clean function) to canonicalize it.
func (Parsed) Compare ¶
Compare returns -1, 0, or 1 according to whether p is less than, equal to, or greater than q. The comparison is elementwise starting with the domain name, then the user name, then the path elements.
func (Parsed) Drop ¶
Drop returns a parsed name with the last n elements dropped. See the comment on DropPath for more information.
func (Parsed) FilePath ¶
FilePath returns just the path under the root directory part of the pathname, without the leading user name or slash.
func (Parsed) First ¶
First returns a parsed name with only the first n elements after the user name. See the comment on FirstPath for more information.
func (Parsed) HasPrefix ¶
HasPrefix reports whether the path has the specified element-wise prefix. That is, it reports whether name is in the subtree starting at root.
func (*Parsed) MarshalJSON ¶
MarshalJSON is needed because Parsed has unexported fields.
func (*Parsed) UnmarshalJSON ¶
UnmarshalJSON is needed because Parsed has unexported fields.