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.
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)
*/Display file contents to standard output.
/**
* Display file contents
* WebAssembly binary: dist/wasm/bin/cat
*
* Usage patterns:
* - cat [file...]
* - Concatenates and displays file contents
*/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)
*/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
*/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)
*/Remove empty directories.
/**
* Remove empty directories
* WebAssembly binary: dist/wasm/bin/rmdir
*
* Usage patterns:
* - rmdir [options] directory...
* - Only removes empty directories by default
*/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)
*/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
*/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)
*/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)
*/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)
*/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 environmentCommon operation patterns:
ls -la /path/to/directorycat filename.txtcp source.txt destination.txtmkdir -p path/to/new/directoryrm -rf unwanted_directorychmod 755 executable_file