{"id":20122837,"url":"https://github.com/freaky/faccess","last_synced_at":"2026-03-27T01:54:32.914Z","repository":{"id":43072621,"uuid":"246973015","full_name":"Freaky/faccess","owner":"Freaky","description":"Cross-platform file access checks in Rust","archived":false,"fork":false,"pushed_at":"2022-03-20T14:06:36.000Z","size":36,"stargazers_count":15,"open_issues_count":2,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-24T17:05:37.834Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","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/Freaky.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-13T02:34:31.000Z","updated_at":"2023-10-15T14:44:02.000Z","dependencies_parsed_at":"2022-09-03T07:21:09.458Z","dependency_job_id":null,"html_url":"https://github.com/Freaky/faccess","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Freaky%2Ffaccess","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Freaky%2Ffaccess/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Freaky%2Ffaccess/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Freaky%2Ffaccess/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Freaky","download_url":"https://codeload.github.com/Freaky/faccess/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224516795,"owners_count":17324399,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-13T19:41:24.648Z","updated_at":"2026-03-27T01:54:32.858Z","avatar_url":"https://github.com/Freaky.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Cargo](https://img.shields.io/crates/v/faccess.svg)][crate]\n[![Documentation](https://docs.rs/faccess/badge.svg)][docs]\n[![CI](https://github.com/Freaky/faccess/workflows/build/badge.svg)][ci]\n\n# faccess\n\nBasic cross-platform file accessibility checks for Rust.\n\n## Synopsis\n\n```rust\npub trait PathExt {\n    fn access(\u0026self, mode: AccessMode) -\u003e std::io::Result\u003c()\u003e;\n    fn readable(\u0026self) -\u003e bool;\n    fn writable(\u0026self) -\u003e bool;\n    fn executable(\u0026self) -\u003e bool;\n}\n\nimpl PathExt for std::path::Path;\n```\n\n## Description\n\n`faccess` provides an extension trait for `std::path::Path` which adds an\n`access` method for checking the accessibility of a path for the given access\npermissions — a bitwise-inclusive OR of one or more `AccessMode` flags\n(`EXISTS`, `READ`, `WRITE`, `EXECUTE`).\n\nIt also provides convenience methods `readable`, `writable`, and `executable`\nif only a single permission needs to be checked in a simple boolean fashion.\n\n## Example\n\n```rust\nuse std::path::Path;\nuse faccess::{AccessMode, PathExt};\n\nlet path = Path::new(\"/bin/ls\");\n\nassert!(path.access(AccessMode::READ | AccessMode::EXECUTE).is_ok());\nassert!(path.readable());\nassert!(!path.writable());\nassert!(path.executable());\n```\n\n## Platform-specific Behaviour\n\nOn Unix platforms, `access` directly maps to [`faccessat(2)`], with the\n`AT_EACCESS` flag used where available to test against the effective user and\ngroup ID's.\n\nOn Windows, a complex custom implementation is used to approximate these\nsemantics in a best-effort fashion, using a mixture of file extension checks,\nsimply attempting to open a file, [`GetNamedSecurityInfoW`], and [`AccessCheck`],\ndepending on the permissions being checked.  This is similar to implementations\nfound in other languages.\n\nOn other platforms it simply proxies to `exists()` and `readonly()` as appropriate.\n\n## Caveats\n\nThere is a history of time-of-check to time-of-use ([TOCTOU]) bugs with this\nclass of function, particularly with set-user-ID programs relying on them to\nvalidate effective user/group permissions prior to accessing files on behalf\nof other users.  They should not be relied upon in a security context.\n\n[`faccessat(2)`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/access.html\n[`GetNamedSecurityInfoW`]: https://docs.microsoft.com/en-us/windows/win32/api/aclapi/nf-aclapi-getnamedsecurityinfow\n[`AccessCheck`]: https://docs.microsoft.com/en-us/windows/win32/api/securitybaseapi/nf-securitybaseapi-accesscheck\n[TOCTOU]: https://en.wikipedia.org/wiki/Time-of-check_to_time-of-use\n[crate]: https://crates.io/crates/faccess\n[docs]: https://docs.rs/faccess\n[ci]: https://github.com/Freaky/faccess/actions?query=workflow%3Abuild\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreaky%2Ffaccess","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffreaky%2Ffaccess","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreaky%2Ffaccess/lists"}