Smb2Pool class
A pool of SMB2 worker isolates for non-blocking parallel operations.
Each worker owns its own SMB connection and runs in a dedicated isolate. All public methods are async and safe to call from the Flutter UI thread.
final pool = await Smb2Pool.connect(
host: '192.168.1.100',
share: 'Music',
user: 'user',
password: 'pass',
workers: 4,
);
final entries = await pool.listDirectory('');
final bytes = await pool.readFile('Artist/cover.jpg');
await pool.disconnect();
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- workerCount → int
-
Number of active workers.
no setter
Methods
-
closeHandle(
Smb2PoolHandle handle) → Future< void> - Close an open file handle.
-
deleteFile(
String path) → Future< void> - Delete a file.
-
disconnect(
) → Future< void> - Disconnect all workers and release resources.
-
echo(
) → Future< void> - Send a keepalive echo to the server.
-
exists(
String path) → Future< bool> - Check whether a file or directory exists.
-
fileSize(
String path) → Future< int> - Get file size in bytes.
-
fsyncHandle(
Smb2PoolHandle handle) → Future< void> - Flush all buffered writes on a file handle to the server.
-
ftruncateHandle(
Smb2PoolHandle handle, int length) → Future< void> -
Truncate an open file handle to
lengthbytes. -
listDirectory(
String path) → Future< List< Smb2DirEntry> > - List all entries in a directory.
- List available shares on the connected server.
-
mkdir(
String path) → Future< void> - Create a directory.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
openFile(
String path) → Future< Smb2PoolHandle> - Open a file for reading and return a handle tied to one worker.
-
openFileWithSize(
String path) → Future< (Smb2PoolHandle, int)> - Open a file and get its size in one call.
-
openFileWrite(
String path) → Future< Smb2PoolHandle> - Open a file for writing and return a handle tied to one worker.
-
readFile(
String path) → Future< Uint8List> - Read an entire file into memory.
-
readFileRange(
String path, {int offset = 0, required int length}) → Future< Uint8List> -
Read
lengthbytes from a file atoffset. -
readFromHandle(
Smb2PoolHandle handle, {int offset = 0, required int length}) → Future< Uint8List> -
Read
lengthbytes atoffsetfrom an open handle. -
readlink(
String path) → Future< String> - Read the target path of a symbolic link.
-
rename(
String oldPath, String newPath) → Future< void> - Rename or move a file or directory.
-
rmdir(
String path) → Future< void> - Delete an empty directory.
-
stat(
String path) → Future< Smb2Stat> - Get file metadata.
-
statvfs(
String path) → Future< Smb2StatVfs> - Get filesystem statistics (total/free space).
-
streamFile(
String path, {int chunkSize = 1024 * 1024}) → Stream< Uint8List> - Stream a file in chunks without loading everything into RAM.
-
streamWrite(
String path, Stream< Uint8List> chunks) → Future<void> - Write data from a Stream to a file without loading everything into RAM.
-
toString(
) → String -
A string representation of this object.
inherited
-
truncate(
String path, int length) → Future< void> -
Truncate a file to
lengthbytes. -
writeFile(
String path, Uint8List data) → Future< void> -
Write
datato a file, creating or truncating it. -
writeFileRange(
String path, Uint8List data, {int offset = 0}) → Future< void> -
Write
datato a file atoffset, creating it if it doesn't exist. -
writeToHandle(
Smb2PoolHandle handle, Uint8List data, {int offset = 0}) → Future< void> -
Write
dataatoffsetto an open write handle.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
connect(
{required String host, String? user, String? password, String? domain, int workers = 4, int timeoutSeconds = 30, String? libPath, bool seal = false, bool signing = false, Smb2Version version = Smb2Version.any}) → Future< Smb2Pool> -
Connect
workersisolates to the SMB share. - List available shares on a server (no active connection needed).