{"id":15130564,"url":"https://github.com/reg499/node-file-attributes","last_synced_at":"2026-02-09T04:06:58.389Z","repository":{"id":257186244,"uuid":"857489143","full_name":"reg499/node-file-attributes","owner":"reg499","description":"A Node.js native addon for managing file attributes on Windows, such as hidden, system, read-only, archive, compression, and indexing.","archived":false,"fork":false,"pushed_at":"2024-09-15T07:38:53.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-08T14:19:08.254Z","etag":null,"topics":["attributes","compression","file","file-attributes","hidden","native-addon","node-gyp","system","windows"],"latest_commit_sha":null,"homepage":"","language":"C++","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/reg499.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2024-09-14T19:39:22.000Z","updated_at":"2024-09-15T07:39:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"cb85fa16-2245-4992-9b16-b76fd374d015","html_url":"https://github.com/reg499/node-file-attributes","commit_stats":null,"previous_names":["reg499/node-file-attributes"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/reg499/node-file-attributes","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reg499%2Fnode-file-attributes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reg499%2Fnode-file-attributes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reg499%2Fnode-file-attributes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reg499%2Fnode-file-attributes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/reg499","download_url":"https://codeload.github.com/reg499/node-file-attributes/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reg499%2Fnode-file-attributes/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29256022,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-09T03:07:45.136Z","status":"ssl_error","status_checked_at":"2026-02-09T03:07:24.123Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["attributes","compression","file","file-attributes","hidden","native-addon","node-gyp","system","windows"],"created_at":"2024-09-26T03:02:34.347Z","updated_at":"2026-02-09T04:06:58.384Z","avatar_url":"https://github.com/reg499.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# File Attributes Manager - Node.js Addon\r\n\r\n**File Attributes Manager** is a Node.js native addon built with C++ for managing file attributes on Windows. It provides a simple interface to set and query various file attributes like hidden, system, read-only, archive, compression, indexing, and more. This addon leverages Windows APIs to interact with file attributes at the OS level, offering more control and precision than what is typically available in standard Node.js modules.\r\n\r\n\r\n## Features\r\n\r\n- **Set file as hidden or visible** (`hide`, `show`)\r\n- **Mark file as system** or remove system attribute (`system`, `nosystem`)\r\n- **Set file as read-only** or make it writable (`readonly`, `writable`)\r\n- **Archive flag management** (`archive`, `noarchive`)\r\n- **Temporary file flag management** (`temporary`, `notemporary`)\r\n- **Set file to normal** (resets all custom attributes)\r\n- **Enable NTFS compression** or remove it (`compress`, `nocompress`)\r\n- **Control content indexing** (`not_indexed`, `indexed`)\r\n- **Multiple attributes** can be applied at once (`e.g., hide,readonly`)\r\n- **Query file attributes** in JSON format\r\n\r\n## Installation\r\n\r\nBefore installing the package, make sure you have Node.js and npm installed on your machine.\r\n\r\nTo install the package, run the following command:\r\n\r\n```bash\r\nnpm install node-file-attributes\r\n```\r\n\r\n\u003e **Note**: This module works only on **Windows** platforms.\r\n\r\n### Prerequisites\r\n\r\n- **Node.js**: Ensure you have Node.js installed. The addon is built using Node.js native addons (C++).\r\n- **Windows OS**: The file attribute management is based on Windows-specific APIs, so this module will only work on Windows environments.\r\n\r\n## Usage\r\n\r\nOnce installed, you can start using the module by importing it into your project. Below are some common examples of how to use the module.\r\n\r\n### Importing the Module\r\n\r\n```javascript\r\nconst {\r\n  setFileAttributes,\r\n  getFileAttributes,\r\n} = require(\"node-file-attributes\");\r\n```\r\n\r\n### Setting File Attributes\r\n\r\nYou can use the `setFileAttributes()` function to set various attributes on a file or folder. The function supports multiple attributes at once.\r\n\r\n```javascript\r\nconst filePath = \"path/to/your/file.txt\";\r\n\r\n// Hide and set the file as read-only\r\nsetFileAttributes(filePath, \"hide,readonly\")\r\n  .then(() =\u003e console.log(\"Attributes set successfully\"))\r\n  .catch((err) =\u003e console.error(\"Error:\", err));\r\n```\r\n\r\n### Querying File Attributes\r\n\r\nTo query the current attributes of a file, use the `getFileAttributes()` function. It returns a JSON object showing the status of different attributes.\r\n\r\n```javascript\r\ngetFileAttributes(filePath)\r\n  .then((attributes) =\u003e console.log(\"File attributes:\", attributes))\r\n  .catch((err) =\u003e console.error(\"Error querying file attributes:\", err));\r\n```\r\n\r\nThe response will be a JSON object like this:\r\n\r\n```json\r\n{\r\n  \"hidden\": true,\r\n  \"system\": false,\r\n  \"readonly\": true,\r\n  \"archive\": true,\r\n  \"temporary\": false,\r\n  \"not_indexed\": false\r\n}\r\n```\r\n\r\n### Available Modes\r\n\r\nYou can set the following modes using the `setFileAttributes()` function:\r\n\r\n| Mode          | Description                                   |\r\n| ------------- | --------------------------------------------- |\r\n| `hide`        | Marks the file as hidden                      |\r\n| `show`        | Makes the file visible (removes hidden flag)  |\r\n| `system`      | Marks the file as a system file               |\r\n| `nosystem`    | Removes the system file flag                  |\r\n| `readonly`    | Sets the file as read-only                    |\r\n| `writable`    | Removes the read-only flag                    |\r\n| `archive`     | Marks the file as archived                    |\r\n| `noarchive`   | Removes the archive flag                      |\r\n| `temporary`   | Marks the file as temporary                   |\r\n| `notemporary` | Removes the temporary flag                    |\r\n| `compress`    | Enables NTFS compression                      |\r\n| `nocompress`  | Disables NTFS compression                     |\r\n| `not_indexed` | Prevents the file from being indexed          |\r\n| `indexed`     | Allows the file to be indexed                 |\r\n| `normal`      | Resets all attributes (makes the file normal) |\r\n\r\nYou can also pass multiple modes as a comma-separated list, e.g., `\"hide,readonly\"`.\r\n\r\n## Example Code\r\n\r\nHere are some more examples of using the module to set different attributes:\r\n\r\n```javascript\r\nconst filePath = \"test-file.txt\";\r\n\r\n/* Set the file as hidden */\r\nsetFileAttributes(filePath, \"hide\")\r\n  .then(() =\u003e console.log(\"File is now hidden\"))\r\n  .catch((err) =\u003e console.error(\"Error:\", err));\r\n\r\n/* Remove the hidden attribute */\r\nsetFileAttributes(filePath, \"show\")\r\n  .then(() =\u003e console.log(\"File is now visible\"))\r\n  .catch((err) =\u003e console.error(\"Error:\", err));\r\n\r\n/* Set the file as read-only */\r\nsetFileAttributes(filePath, \"readonly\")\r\n  .then(() =\u003e console.log(\"File is now read-only\"))\r\n  .catch((err) =\u003e console.error(\"Error:\", err));\r\n\r\n/* Remove the read-only attribute */\r\nsetFileAttributes(filePath, \"writable\")\r\n  .then(() =\u003e console.log(\"File is now writable\"))\r\n  .catch((err) =\u003e console.error(\"Error:\", err));\r\n\r\n/* Query current file attributes */\r\ngetFileAttributes(filePath)\r\n  .then((attributes) =\u003e console.log(\"File attributes:\", attributes))\r\n  .catch((err) =\u003e console.error(\"Error:\", err));\r\n```\r\n\r\n## Building from Source\r\n\r\nIf you want to build the addon from the source code, you can clone the repository and run the following commands:\r\n\r\n```bash\r\n# Install dependencies\r\nnpm install\r\n\r\n# Build the addon\r\nnpm run build\r\n```\r\n\r\nThis will compile the C++ code and generate the necessary bindings for Node.js.\r\n\r\n## Contributing\r\n\r\nContributions are welcome! If you encounter any issues, feel free to create a GitHub issue or submit a pull request. Make sure to follow the coding standards and best practices when contributing.\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freg499%2Fnode-file-attributes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freg499%2Fnode-file-attributes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freg499%2Fnode-file-attributes/lists"}