FilePath class

A class to make it easier to manipulate file system entites. Once paths or entites are converted into Paths, they can be easily copied, deleted, joined, and their name retrieved.

Constructors

FilePath(dynamic entityOrString)
Create a new FilePath. The entityOrString parameter can be a FileSystemEntity or a String. If a String, this method converts the given path from a platform independent one to a platform dependent path. This conversion will work for relative paths but wouldn't make sense to use for absolute ones.

Properties

asDirectory Directory
Assume the current file system entity is a Directory and return it as such. You would call this instead of entity when the file system entity does not yet exist.
no setter
asFile File
Assume the current file system entity is a File and return it as such. You would call this instead of entity when the file system entity does not yet exist.
no setter
Assume the current file system entity is a Link and return it as such. You would call this instead of entity when the file system entity does not yet exist.
no setter
entity FileSystemEntity?
no setter
exists bool
Return whether an entity actually exists for this path. The entity could be a File, Directory, or Link.
no setter
hashCode int
The hash code for this object.
no setteroverride
isDirectory bool
no setter
isFile bool
no setter
no setter
length int
Return the file length; if this FilePath is not a File, return 0.
no setter
name String?
no setter
parent FilePath?
Returns the containing Path. Returns a non-null value even if this is a root directory.
no setter
path String
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

copy(FilePath destDir) FilePath
Copy the the entity to the given destination. Return the newly created FilePath.
createDirectory({bool recursive = false}) Directory
Synchronously create the directory. See also Directory.createSync.
createFile({bool recursive = false}) File
Synchronously create the file. See also File.createSync.
Synchronously create the link. See also Link.createSync.
delete() → void
Delete the entity at the path.
join([dynamic arg0, String? arg1, String? arg2, String? arg3, String? arg4, String? arg5, String? arg6, String? arg7, String? arg8, String? arg9]) FilePath
Join the given path elements to this path, and return a new FilePath object.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
override

Static Properties

current FilePath
no setter

Static Methods

createSystemTemp([String? prefix]) FilePath
Creates a temporary directory in the system temp directory. See Directory.systemTemp and Directory.createTempSync. If prefix is missing or null, the empty string is used for prefix.