FileSync class

Provides a set of methods to read/write a file synchronisly.

The class is mostly used internally.

Note: the api to this class is considered EXPERIMENTAL and is subject to change.

Constructors

FileSync(String path, {FileMode fileMode = FileMode.writeOnlyAppend})
Opens a file for synchronous IO.

Properties

hashCode int
The hash code for this object.
no setterinherited
length int
Returns the length of the file in bytes The file does NOT have to be open to determine its length. See:
no setter
path String
The path to this file.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

append(String line, {String? newline}) → void
Appends the line to the file Appends newline after the line. If newline is null or isn't passed then the platform end of line characters are appended as defined by Platform().eol. Pass null or an '' to newline to not add a line terminator.
close() → void
Close and flushes the file to disk.
flush() → void
Flushes the contents of the file to disk.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
read(CancelableLineAction lineAction) → void
reads every line from a file calling the passed lineAction for each line. if you return false from a lineAction call then the read returns and no more lines are read.
readIntoSync(List<int> buffer, [int start = 0, int? end]) int
Exposed the RandomFileAccess method readIntoSync Synchronously reads into an existing buffer.
readLine({String? lineDelimiter}) String?
Reads a single line from the file. lineDelimiter the end of line delimiter.
This is just a wrapper for the method File.resolveSymbolicLinksSync. Returns the path the symbolic link links to.
toString() String
A string representation of this object.
inherited
truncate() → void
Truncates the file to zero bytes in length.
write(String line, {String? newline}) → void
Truncates the file to zero bytes and then writes the given text to the file. If newline is null or isn't passed then the platform end of line characters are appended as defined by Platform().eol. Pass null or an '' to newline to not add a line terminator.
writeFromSync(List<int> buffer, [int start = 0, int? end]) → void
Exposed the RandomFileAccess method writeFromSync.

Operators

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

Static Methods

tempFile({String? suffix}) String
Generates a temporary filename in the system temp directory that is guaranteed to be unique.