@nova-lang/fs
v0.2.1
Published
Nova file system library — read, write, copy, move, glob, and path utilities
Readme
@nova-lang/fs
Nova file system library — read, write, copy, move, glob, and path utilities.
Install
npm install @nova-lang/fsUsage
@use "nova/fs"Read
| Function | Description |
|----------|-------------|
| fs-read(path) | Read file as UTF-8 string |
| fs-read-binary(path) | Read file as buffer |
| fs-read-lines(path) | Read file lines as array |
| fs-read-json(path) | Read and parse JSON file |
Write
| Function | Description |
|----------|-------------|
| fs-write(path, content) | Write string to file |
| fs-write-binary(path, content) | Write buffer to file |
| fs-write-json(path, data, pretty) | Write JSON to file |
| fs-append(path, content) | Append to file |
File Management
| Function | Description |
|----------|-------------|
| fs-copy(src, dest) | Copy file |
| fs-copy-dir(src, dest) | Copy directory recursively |
| fs-move(src, dest) | Move/rename file |
| fs-remove(path) | Delete file |
| fs-truncate(path, len) | Truncate file |
| fs-touch(path) | Create empty file or update mtime |
| fs-ensure-file(path) | Create file if not exists |
| fs-empty-file(path) | Empty file contents |
Stats & Metadata
| Function | Description |
|----------|-------------|
| fs-exists(path) | Check if path exists |
| fs-stat(path) | Get file stats |
| fs-lstat(path) | Get link stats |
| fs-is-file(path) | Check if path is a file |
| fs-is-dir(path) | Check if path is a directory |
| fs-is-symlink(path) | Check if path is a symlink |
| fs-empty(path) | Check if file is empty |
| fs-size(path) | Get file size in bytes |
| fs-mode(path) | Get file mode |
| fs-atime(path) | Get access time |
| fs-mtime(path) | Get modification time |
| fs-ctime(path) | Get change time |
| fs-birthtime(path) | Get creation time |
Symlinks
| Function | Description |
|----------|-------------|
| fs-symlink(target, path) | Create symbolic link |
| fs-hardlink(target, path) | Create hard link |
| fs-read-link(path) | Read link target |
| fs-realpath(path) | Resolve to absolute path |
Permissions
| Function | Description |
|----------|-------------|
| fs-chmod(path, mode) | Change file mode |
| fs-chown(path, uid, gid) | Change file owner |
| fs-access(path, mode) | Check access permissions |
| fs-readable(path) | Check if readable |
| fs-writable(path) | Check if writable |
| fs-executable(path) | Check if executable |
Directories
| Function | Description |
|----------|-------------|
| fs-list(dir) | List directory contents |
| fs-mkdir(dir) | Create directory |
| fs-ensure-dir(dir) | Create directory recursively |
| fs-rmdir(dir) | Remove empty directory |
| fs-empty-dir(dir) | Empty directory contents |
| fs-tree(dir) | Get directory tree |
| fs-find(dir, name) | Find files by name |
File Descriptors
| Function | Description |
|----------|-------------|
| fs-open(path, flags) | Open file descriptor |
| fs-close(fd) | Close file descriptor |
| fs-fstat(fd) | Get fd stats |
| fs-read-fd(fd, buffer, offset, length, position) | Read from fd |
| fs-write-fd(fd, buffer, offset, length, position) | Write to fd |
Streams
| Function | Description |
|----------|-------------|
| fs-create-read-stream(path) | Create readable stream |
| fs-create-write-stream(path) | Create writable stream |
Timestamps
| Function | Description |
|----------|-------------|
| fs-utimes(path, atime, mtime) | Change file timestamps |
Glob
| Function | Description |
|----------|-------------|
| fs-glob(pattern) | Glob all entries |
| fs-glob-files(pattern) | Glob files only |
| fs-glob-dirs(pattern) | Glob directories only |
Path Utilities
| Function | Description |
|----------|-------------|
| fs-path-join(parts) | Join path segments |
| fs-path-basename(p) | Get file basename |
| fs-path-dirname(p) | Get directory name |
| fs-path-extname(p) | Get file extension |
| fs-path-resolve(p) | Resolve to absolute path |
| fs-path-relative(from, to) | Get relative path |
| fs-path-parse(p) | Parse path into object |
| fs-path-sep() | Get path separator |
| fs-path-delimiter() | Get path delimiter |
| fs-path-is-absolute(p) | Check if absolute |
| fs-path-normalize(p) | Normalize path |
| fs-path-format(obj) | Format path from object |
Temp Files
| Function | Description |
|----------|-------------|
| fs-tmpdir() | Get temp directory |
| fs-tmpfile(ext) | Create temp file |
| fs-tmpname(ext) | Generate temp filename |
Disk
| Function | Description |
|----------|-------------|
| fs-disk-free(path) | Get free disk space |
| fs-disk-total(path) | Get total disk space |
Working Directory
| Function | Description |
|----------|-------------|
| fs-chdir(dir) | Change working directory |
| fs-cwd() | Get current working directory |
| fs-homedir() | Get home directory |
| fs-tmpdir-os() | Get OS temp directory |
| fs-dev-null() | Get /dev/null path |
License
MIT
