or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

file-operations.mdindex.mdlogic-math.mdmisc-utilities.mdpath-utilities.mdsystem-utilities.mdtext-processing.md
tile.json

file-operations.mddocs/

File Operations

Essential file system operations for managing files and directories in the WebAssembly environment. These utilities provide the core functionality for file manipulation, directory navigation, and permission management.

Capabilities

Directory Listing

List directory contents with various formatting and filtering options.

/**
 * List directory contents
 * WebAssembly binary: dist/wasm/bin/ls
 * 
 * Usage patterns:
 * - ls [options] [directory...]
 * - Supports -l (long format), -a (all files), -h (human readable)
 */

File Display

Display file contents to standard output.

/**
 * Display file contents
 * WebAssembly binary: dist/wasm/bin/cat
 * 
 * Usage patterns:
 * - cat [file...]
 * - Concatenates and displays file contents
 */

File Copying

Copy files and directories with preservation of attributes.

/**
 * Copy files and directories
 * WebAssembly binary: dist/wasm/bin/cp
 * 
 * Usage patterns:
 * - cp [options] source destination
 * - cp [options] source... directory
 * - Supports -r (recursive), -p (preserve attributes)
 */

File Moving

Move or rename files and directories.

/**
 * Move or rename files and directories
 * WebAssembly binary: dist/wasm/bin/mv
 * 
 * Usage patterns:
 * - mv source destination
 * - mv source... directory
 * - Atomic rename operation when possible
 */

File Removal

Remove files from the file system.

/**
 * Remove files
 * WebAssembly binary: dist/wasm/bin/rm
 * 
 * Usage patterns:
 * - rm [options] file...
 * - Supports -r (recursive), -f (force), -i (interactive)
 */

Directory Removal

Remove empty directories.

/**
 * Remove empty directories
 * WebAssembly binary: dist/wasm/bin/rmdir
 * 
 * Usage patterns:
 * - rmdir [options] directory...
 * - Only removes empty directories by default
 */

Directory Creation

Create directories with optional parent creation.

/**
 * Create directories
 * WebAssembly binary: dist/wasm/bin/mkdir
 * 
 * Usage patterns:
 * - mkdir [options] directory...
 * - Supports -p (create parents), -m (set mode)
 */

Permission Modification

Change file and directory permissions.

/**
 * Change file permissions
 * WebAssembly binary: dist/wasm/bin/chmod
 * 
 * Usage patterns:
 * - chmod mode file...
 * - chmod [references][operator][modes] file...
 * - Supports octal and symbolic notation
 */

Link Creation

Create hard and symbolic links between files.

/**
 * Create links between files
 * WebAssembly binary: dist/wasm/bin/ln
 * 
 * Usage patterns:
 * - ln [options] target linkname
 * - ln [options] target... directory
 * - Supports -s (symbolic links), -f (force)
 */

File Timestamps

Update file access and modification timestamps.

/**
 * Update file timestamps
 * WebAssembly binary: dist/wasm/bin/touch
 * 
 * Usage patterns:
 * - touch [options] file...
 * - Creates empty files if they don't exist
 * - Supports -t (set specific time), -r (reference file)
 */

File Status

Display detailed file and directory information.

/**
 * Display file status information
 * WebAssembly binary: dist/wasm/bin/stat
 * 
 * Usage patterns:
 * - stat [options] file...
 * - Shows size, permissions, timestamps, and inode information
 * - Supports -f (filesystem status), -c (custom format)
 */

Usage Examples

Basic file operations:

const { path } = require("@cowasm/coreutils");
const { join } = require("path");

// Access to individual utility binaries
const binPath = join(path, "bin");
const lsBinary = join(binPath, "ls");
const catBinary = join(binPath, "cat");
const cpBinary = join(binPath, "cp");

// These would be executed via your WebAssembly runtime
// Exact execution method depends on your WASM environment

Common operation patterns:

  • File listing: ls -la /path/to/directory
  • File viewing: cat filename.txt
  • File copying: cp source.txt destination.txt
  • Directory creation: mkdir -p path/to/new/directory
  • File removal: rm -rf unwanted_directory
  • Permission setting: chmod 755 executable_file

Notes

  • All utilities operate within the WebAssembly virtual file system
  • File paths are relative to the WASM runtime's current working directory
  • Some operations may have limitations compared to native Unix implementations
  • Error handling follows standard Unix conventions with exit codes