Documentation
¶
Overview ¶
Package path provides methods and a type for working with slash-separated paths with selectors.
Package Path provides methods and a type for working with slash-separated path strings.
Index ¶
- type ToDirectory
- type ToFile
- func (s ToFile) Directory() ToDirectory
- func (s ToFile) FileExtension() String.Readable
- func (s ToFile) FileName() string
- func (s ToFile) IsAbsolute() bool
- func (s ToFile) IsRelative() bool
- func (s ToFile) MarshalText() ([]byte, error)
- func (s ToFile) Parent() ToDirectory
- func (s ToFile) String() string
- func (s *ToFile) UnmarshalText(text []byte) error
- func (s ToFile) WithoutExtension() ToFile
- type ToNode
- func (s ToNode) Element(i int) String.Readable
- func (s ToNode) Hash() uint32
- func (s ToNode) IsAbsolute() bool
- func (s ToNode) IsEmpty() bool
- func (s ToNode) MarshalText() ([]byte, error)
- func (s ToNode) Name(i int) String.Readable
- func (s ToNode) NumElement() int
- func (s ToNode) NumName() int
- func (s ToNode) PrefixedWithSelector() ToNode
- func (s ToNode) Selector() String.Readable
- func (s ToNode) StartingFrom(start int) ToNode
- func (s ToNode) String() string
- func (s *ToNode) UnmarshalText(text []byte) error
- func (s ToNode) WithoutSelector() ToNode
- type ToResource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ToDirectory ¶
ToDirectory semantically represents a path to what is expected to be a directory/folder on the filesystem.
func AsDirectory ¶
func AsDirectory[T String.Any](path T) ToDirectory
AsDirectory returns the given path as a directory.
func (ToDirectory) MarshalText ¶
func (s ToDirectory) MarshalText() ([]byte, error)
func (ToDirectory) String ¶
func (s ToDirectory) String() string
func (*ToDirectory) UnmarshalText ¶
func (s *ToDirectory) UnmarshalText(text []byte) error
type ToFile ¶
ToFile represents a path to a file within a filesystem.
A path is composed of slash-separated (/) names and period-separated (.) extensions. ".." and "." are special names. They refer to the parent and the current element respectively.
The following examples are paths relative to the current element:
"A" // Points to the direct child A. "A/B" // Points to A's child B. "." // Points to the current element. ".." // Points to the parent element. "../C" // Points to the sibling element C. "../.." // Points to the grandparent element. "/root" // Points to the root element.
func (ToFile) Directory ¶
func (s ToFile) Directory() ToDirectory
Directory returns the directory if the string is a valid file path.
func (ToFile) FileExtension ¶
FileExtension returns the file extension without the leading period (.) if the string is a valid file name or path. Otherwise, returns an empty string.
func (ToFile) FileName ¶
FileName returns the file name, including the extension, if the string is a valid file path,
func (ToFile) IsAbsolute ¶
IsAbsolute returns true if the path's starting point is explicitly defined. Unlike a relative path, an absolute path is represented by a leading slash character (/). This method is the opposite of ToFile.IsRelative.
This includes all paths starting with "res://", "user://", "C:\", "/", etc.
func (ToFile) IsRelative ¶
IsRelative returns true if the string is a path, and its starting point is dependent on context. The path could begin from the current directory, or the current Node (if the string is derived from a NodePath), and may sometimes be prefixed with "./". This method is the opposite of ToFile.IsAbsolute.
func (ToFile) MarshalText ¶
func (ToFile) Parent ¶
func (s ToFile) Parent() ToDirectory
Parent returns the parent directory if the directory is valid.
func (*ToFile) UnmarshalText ¶
func (ToFile) WithoutExtension ¶
WithoutExtension returns the path before the last period character (.) in the path.
type ToNode ¶
ToNode represents a path to a generic node within a tree.
A path is composed of slash-separated (/) names and colon-separated (:) selectors. ".." and "." are special names. They refer to the parent and the current element respectively.
The following examples are paths relative to the current element:
"A" // Points to the direct child A. "A/B" // Points to A's child B. "." // Points to the current element. ".." // Points to the parent element. "../C" // Points to the sibling element C. "../.." // Points to the grandparent element. "/root" // Points to the root element. ":Position" // Points to this items's position. ":Position:X" // Points to this items's position in the x axis. "Camera3D:Rotation:Y" // Points to the child Camera3D and its y rotation. "/root:Size:X" // Points to the root Window and its width.
func (ToNode) Hash ¶
Hash returns the 32-bit hash value representing the paths contents.
Note: paths with equal hash values are not guaranteed to be the same, as a result of hash collisions. Paths with different hash values are guaranteed to be different.
func (ToNode) IsAbsolute ¶
IsAbsolute returns true if the path's starting point is explicitly defined. Unlike a relative path, an absolute path is represented by a leading slash character (/). This method is the opposite of [ToNode.IsRelative].
This includes all paths starting with "res://", "user://", "C:\", "/", etc.
func (ToNode) MarshalText ¶
func (ToNode) NumElement ¶
NumElement returns the number of elements in the path.
func (ToNode) PrefixedWithSelector ¶
PrefixedWithSelector returns a copy of this path with a period character (.) prefixed, transforming it to a pure selector with no items (relative to the current item).
func (ToNode) StartingFrom ¶
StartingFrom returns a slice of the path from the given start index to the end of the path.
func (*ToNode) UnmarshalText ¶
func (ToNode) WithoutSelector ¶
WithoutSelector returns the path up until the first selector.
type ToResource ¶
type ToResource = ToFile