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
Methods
-
delete(
File file, {bool recursive = false}) → Future< void> -
Deletes
fileunder the current concurrency limit. -
exists(
File file) → Future< bool> -
Checks whether the given
fileexists, 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
filewith controlled concurrency. -
setSemaphoreLimit(
int limit) → void - Updates the maximum concurrency level for file operations.
-
stat(
File file) → Future< FileStat> -
Retrieves metadata for
filewith 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
bytestofilewith 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.