{"id":22521801,"url":"https://github.com/ncpa0/fs-gjs","last_synced_at":"2026-02-10T13:32:27.379Z","repository":{"id":163108093,"uuid":"637943015","full_name":"ncpa0/fs-gjs","owner":"ncpa0","description":"Collection of file system utility functions for Gnome JavaScript (GJS).","archived":false,"fork":false,"pushed_at":"2024-12-14T16:44:47.000Z","size":1464,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-19T20:49:28.754Z","etag":null,"topics":["filesystem","gjs","gnome","gnome-javascript","input-output"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ncpa0.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-05-08T18:40:06.000Z","updated_at":"2024-12-14T16:44:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"7eb60740-5af9-4f59-bb64-c3bce7f88bea","html_url":"https://github.com/ncpa0/fs-gjs","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/ncpa0/fs-gjs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ncpa0%2Ffs-gjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ncpa0%2Ffs-gjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ncpa0%2Ffs-gjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ncpa0%2Ffs-gjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ncpa0","download_url":"https://codeload.github.com/ncpa0/fs-gjs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ncpa0%2Ffs-gjs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29300648,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-10T12:55:56.056Z","status":"ssl_error","status_checked_at":"2026-02-10T12:55:55.692Z","response_time":65,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["filesystem","gjs","gnome","gnome-javascript","input-output"],"created_at":"2024-12-07T05:13:00.759Z","updated_at":"2026-02-10T13:32:27.286Z","avatar_url":"https://github.com/ncpa0.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fs-gjs\n\nCollection of file system utility functions for [Gnome JavaScript (GJS)](https://gitlab.gnome.org/GNOME/gjs).\n\n## Usage\n\n`fs-gjs` provides two sets of functions, synchronous and asynchronous. First can be accessed vias `SyncFs` class and the latter via `Fs` class. Both have almost exactly the same API, with the only difference that asynchronous functions need to be awaited.\n\n1. [Reading files](#reading-files)\n2. [Writing files](#writing-files)\n3. [Appending to files](#appending-to-files)\n4. [Copying files](#copying-files)\n5. [Moving files](#moving-files)\n6. [Deleting files](#deleting-files)\n7. [Creating directories](#creating-directories)\n8. [Create symbolic links](#create-symbolic-links)\n9. [Change file permissions](#change-file-permissions)\n10. [Change file ownership](#change-file-ownership)\n11. [List directory contents](#list-directory-contents)\n12. [Check if file exists](#check-if-file-exists)\n13. [Get file info](#get-file-info)\n14. [IOStreams](#iostreams)\n\n### Reading files\n\n```ts\nimport { Fs } from \"./node_modules/fs-gjs/index.js\";\n\n// Read file as bytes\nconst bytes = await Fs.readFile(\"/path/to/file\");\n\n// Read file as text\nconst text = await Fs.readTextFile(\"/path/to/file\");\n```\n\n### Writing files\n\n```ts\nimport { Fs } from \"./node_modules/fs-gjs/index.js\";\n\n// Write bytes to file\nconst bytes = new Uint8Array([1, 2, 3]);\nawait Fs.writeFile(\"/path/to/file\", bytes);\n\n// Write text to file\nconst text = \"Hello, world!\";\nawait Fs.writeTextFile(\"/path/to/file\", text);\n```\n\n### Appending to files\n\n```ts\nimport { Fs } from \"./node_modules/fs-gjs/index.js\";\n\n// Append bytes to file\nconst bytes = new Uint8Array([1, 2, 3]);\nawait Fs.appendFile(\"/path/to/file\", bytes);\n\n// Append text to file\nconst text = \"Hello, world!\";\nawait Fs.appendTextFile(\"/path/to/file\", text);\n```\n\n### Copying files\n\n```ts\nimport { Fs } from \"./node_modules/fs-gjs/index.js\";\n\nawait Fs.copyFile(\"/path/to/source\", \"/path/to/destination\");\n```\n\n### Moving files\n\n```ts\nimport { Fs } from \"./node_modules/fs-gjs/index.js\";\n\nawait Fs.moveFile(\"/path/to/source\", \"/path/to/destination\");\n```\n\n### Deleting files\n\n```ts\nimport { Fs } from \"./node_modules/fs-gjs/index.js\";\n\n// Permanently delete file\nawait Fs.deleteFile(\"/path/to/file\");\n\n// Move file to trash\nawait Fs.deleteFile(\"/path/to/file\", { trash: true });\n```\n\n### Creating directories\n\n```ts\nimport { Fs } from \"./node_modules/fs-gjs/index.js\";\n\nawait Fs.makeDir(\"/path/to/directory\");\n```\n\n### Create symbolic links\n\n```ts\nimport { Fs } from \"./node_modules/fs-gjs/index.js\";\n\nawait Fs.makeLink(\"/path/to/link\", \"/path/to/target\");\n```\n\n### Change file permissions\n\n```ts\nimport { Fs } from \"./node_modules/fs-gjs/index.js\";\n\nawait Fs.chmod(\"/path/to/file\", 0o755);\n// or\nawait Fs.chmod(\"/path/to/file\", \"rwxr-xr-x\");\n// or\nawait Fs.chmod(\"/path/to/file\", {\n  owner: { read: true, write: true, execute: true },\n  group: { read: true, write: false, execute: true },\n  others: { read: true, write: false, execute: true },\n});\n```\n\n### Change file ownership\n\n```ts\nimport { Fs } from \"./node_modules/fs-gjs/index.js\";\n\nawait Fs.chown(\"/path/to/file\", /* uid */ 1000, /* gid */ 1000);\n```\n\n### List directory contents\n\n```ts\nimport { Fs } from \"./node_modules/fs-gjs/index.js\";\n\n// get array of FileInfo objects\nawait Fs.listDir(\"/path/to/directory\");\n\n// get array of file names\nawait Fs.listFilenames(\"/path/to/directory\");\n```\n\n### Check if file exists\n\n```ts\nimport { Fs } from \"./node_modules/fs-gjs/index.js\";\n\nawait Fs.fileExists(\"/path/to/file\");\n```\n\n### Get file info\n\n```ts\nimport { Fs } from \"./node_modules/fs-gjs/index.js\";\n\nawait Fs.fileInfo(\"/path/to/file\");\n```\n\n### IOStreams\n\nIOStreams can be opened in one of three modes:\n\n- `CREATE` - a new file will be created, will fail if file already exists\n- `REPLACE` - a new file will be created, will replace existing file if it exists\n- `OPEN` - an existing file will be opened, will fail if file does not exist\n\n```ts\nimport { Fs } from \"./node_modules/fs-gjs/index.js\";\n\nconst stream = await Fs.openIOStream(\"/path/to/file\", \"CREATE\");\n\n// Read the first 1024 bytes from stream\nconst bytes = await stream.read(1024);\n\n// Read all the remaining bytes from stream\nconst bytes = await stream.readAll();\n\n// Write bytes to stream\nconst bytes = new Uint8Array([1, 2, 3]);\nawait stream.write(bytes);\n\n// Skip 1024 bytes from the stream\nawait stream.skip(1024);\n\n// Move cursor position by 1024 bytes forward\nawait stream.seek(1024);\n\n// Move cursor to 1024 from the stream start\nawait stream.seekFromStart(1024);\n\n// Move cursor to 1024 from the stream end\nawait stream.seekFromEnd(1024);\n\n// Truncate the stream to the length of 1024 bytes\nawait stream.truncate(1024);\n\n// Get current cursor position\nconst position = await stream.currentPosition();\n\n// Close the stream\nawait stream.close();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fncpa0%2Ffs-gjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fncpa0%2Ffs-gjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fncpa0%2Ffs-gjs/lists"}