FileLimited class

A concurrency guard for file system operations.

This class wraps common dart:io file APIs with a shared semaphore to avoid excessive parallel access, preventing Too many open files errors and reducing I/O contention — especially on SSDs, NFS/S3-backed storage, CI machines, or containerized environments.

The semaphore applies globally to all operations performed through this instance.

Default concurrency limit: 50.

Constructors

FileLimited({String? name, int semaphoreLimit = defaultSemaphoreLimit})

Properties

hashCode int
The hash code for this object.
no setterinherited
name String?
Instance identifier used for debugging or logging purposes.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

delete(File file, {bool recursive = false}) Future<void>
Deletes file under the current concurrency limit.
exists(File file) Future<bool>
Checks whether the given file exists, using the current concurrency limit.
getSemaphoreLimit() int
Returns the current concurrency limit for file operations.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
readAsBytes(File file) Future<Uint8List>
Reads all bytes from file with controlled concurrency.
setSemaphoreLimit(int limit) → void
Updates the maximum concurrency level for file operations.
stat(File file) Future<FileStat>
Retrieves metadata for file with concurrency control.
toString() String
A string representation of this object.
override
writeAsBytes(File file, List<int> bytes, {FileMode mode = FileMode.write, bool flush = false}) Future<File>
Writes bytes to file with controlled concurrency.

Operators

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

Static Properties

global FileLimited
A shared singleton instance of FileLimited.
final

Constants

defaultSemaphoreLimit → const int
Default semaphore limit across all operations.