file_lualike 0.1.2 copy "file_lualike: ^0.1.2" to clipboard
file_lualike: ^0.1.2 copied to clipboard

Adapter that bridges package:file FileSystem implementations (SFTP, memory, local) into the lualike scripting runtime. Enables transparent filesystem backends for io.open(), os.remove(), dofile(), and [...]

file_lualike #

Pub Version Pub Version License

Bridges package:file FileSystem implementations into the LuaLike scripting runtime. Enables transparent filesystem backends for io.open(), os.remove(), dofile(), module loading, and all other lualike file operations.

Use any package:file-compatible filesystem — local disk, in-memory (MemoryFileSystem), SFTP (file_sftp), or a custom implementation — without changing a single line of Lua code.

Install #

dependencies:
  lualike: ^0.3.0
  file_lualike: ^0.1.2

Then run:

dart pub get

Quick start #

import 'package:lualike/lualike.dart';
import 'package:file_lualike/file_lualike.dart';
import 'package:file/local.dart';

Future<void> main() async {
  final lua = LuaLike();

  // Use the local filesystem (dart:io under the hood)
  await useFileSystem(const LocalFileSystem());

  lua.expose('greet', (List<Object?> args) {
    return Value('Hello, ${args.first ?? 'world'}!');
  });

  final result = await lua.execute('''
    local f = io.open("/tmp/hello.txt", "w")
    f:write("Hello from LuaLike!")
    f:close()
    return greet("file written")
  ''');

  print((result as Value).unwrap());
}

Usage #

Wiring into lualike #

Call useFileSystem(fs) once during setup. It wires two integration points:

  1. File providerio.open(), io.lines(), etc. create PackageFileIODevice instances backed by your FileSystem.
  2. Metadata backendos.remove(), dofile(), module loading, and other filesystem metadata operations delegate to your FileSystem.
await useFileSystem(yourFileSystem);

In-memory filesystem (testing) #

import 'package:file/memory.dart';
import 'package:file_lualike/file_lualike.dart';

final fs = MemoryFileSystem();
await useFileSystem(fs);

// All file operations now happen in memory

SFTP filesystem (remote) #

import 'package:file_lualike/file_lualike.dart';
import 'package:file_sftp/file_sftp.dart';

final sftp = SftpFileSystem(SftpConfig(
  host: 'example.com',
  username: 'alice',
  password: 'secret',
  root: '/home/alice/project',
));

await useFileSystem(sftp);

// All file operations transparently go over SFTP

Custom FileSystemProvider #

For advanced scenarios where you need fine-grained control over the provider:

final provider = FileSystemProvider();
await useFileSystem(fs, provider: provider);

Targeted provider override #

If you need only the metadata backend without changing the I/O provider:

import 'package:lualike/lualike.dart';

setFileSystemBackend(PackageFileSystemBackend(fs));
0
likes
0
points
172
downloads

Publisher

verified publisherglenfordwilliams.com

Weekly Downloads

Adapter that bridges package:file FileSystem implementations (SFTP, memory, local) into the lualike scripting runtime. Enables transparent filesystem backends for io.open(), os.remove(), dofile(), and all other lualike file operations.

Repository (GitHub)
View/report issues

Topics

#lua #scripting #filesystem #sftp #adapter

License

unknown (license)

Dependencies

file, lualike

More

Packages that depend on file_lualike