utils/path/path_utils library

Path manipulation utilities ported from Neomage TypeScript.

Provides path normalization, glob matching, gitignore parsing, prefix-based trie lookup, and file system watching primitives.

Classes

FileEvent
A file system event emitted by FileWatcher.
FileWatcher
Watches a file or directory for changes, emitting FileEvents.
GitignoreParser
Parses .gitignore-style patterns and determines whether paths are ignored.
GlobMatcher
Compiles shell-style glob patterns to RegExp and matches paths.
PathTrie<T>
Efficient prefix-based path lookup using a trie structure.
WatcherConfig
Configuration for FileWatcher.

Enums

FileEventType
The type of file system change observed.

Functions

changeExtension(String path, String newExt) String
Returns path with its extension changed to newExt.
expandHome(String path) String
Expands a leading ~ to the current user's home directory.
findCommonAncestor(List<String> paths) String
Finds the longest common ancestor directory of the given paths.
fromUri(Uri uri) String
Converts a file:// uri back to a platform path string.
getExtension(String path) String
Returns the file extension of path including the dot, or empty string.
isAbsolute(String path) bool
Returns true if path is an absolute path.
isHidden(String path) bool
Returns true when the final component of path starts with ..
isSubPath(String parent, String child) bool
Returns true if child is a sub-path of parent.
joinPaths(List<String> parts) String
Joins path parts with the platform separator, normalizing the result.
normalizePath(String path) String
Normalizes a file-system path by collapsing separators, resolving . and .. segments, and converting backslashes to forward slashes.
relativePath(String from, String to) String
Computes the relative path from from to to.
sanitizePath(String path) String
Removes dangerous characters from path that could cause security issues.
splitPath(String path) → ({String basename, String dir, String ext})
Splits path into (directory, basename, extension).
toUri(String path) Uri
Converts a file-system path to a file:// Uri.