Files & Directories

Files & Directories

Working with the client's file system

Terminalwire makes it possible to read and write files on the client’s file system, but only if they grant access.

Security

First let’s talk about security. Be default, Terminalwire servers can only read/write files to the ~/.terminalwire/authorities/$AUTHORITY/storage path. This is primarly used to store session tokens, similar to how web browsers store cookies on workstations.

All other paths are denied access. Only the client can grant access to other paths on the client’s file system.

Files

Working with files on a client’s file system is similar to working with files on a server. You can read, write, and delete files. Here’s some code:

# Write a file to the client's file system at
# ~/.terminalwire/authorities/$AUTHORITY/storage/hello.txt
context.file.write storage_path.join("hello.txt"), "Hello, World!"

Directories

Working with directories on a client’s file system is similar to working with directories on a server. You can create, delete, and list directories. Here’s some code:

# List all of the files in the client's file system in their Terminalwire storage path.
context.dir.glob storage_path