remote_file_system_interface 0.1.1 remote_file_system_interface: ^0.1.1 copied to clipboard
An interface for file system utilities for a remote client.
An interface for file system utilities for a remote client.
About #
This package provides the facilities to interact with the file system of a remote client with the same APIs and methods as the file system from dart:io
.
Synchronous methods are not supported, because interactions with a remote client are inherently asynchronous.
RemoteFile
instances returned by RemoteFileSystemInterface.file()
or RemoteDirectory
instances returned by RemoteFileSystemInterface.directory()
all implement the File
or Directory
interface from dart:io
for seamless usage and integration in existing code bases.
Usage #
Extend the class RemoteFileSystemInterface
and implement all required methods.
final class MySshFileSystem extends RemoteFileSystemInterface {
...
static Future<MySshFileSystem> connect(...) async {
...
}
...
}
Future<void> main() async {
final fs = await MySshFileSystem.connect(...);
// Print the current directory in the remote file system.
print(fs.currentDirectory);
// Get a RemoteFile in the current directory.
final file = fs.file("test.txt");
// Open file for writing.
final oSink = file.openWrite();
...
}
Example #
For a full example implementation, see ssh_file_system.