Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marcospb19/permissions
Library to query file permissions (read, write, execute, remove and create)
https://github.com/marcospb19/permissions
filesystem library permissions rust
Last synced: 3 months ago
JSON representation
Library to query file permissions (read, write, execute, remove and create)
- Host: GitHub
- URL: https://github.com/marcospb19/permissions
- Owner: marcospb19
- License: mit
- Created: 2020-09-14T04:31:57.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-09-16T19:05:24.000Z (over 1 year ago)
- Last Synced: 2024-04-24T00:41:21.879Z (9 months ago)
- Topics: filesystem, library, permissions, rust
- Language: Rust
- Homepage: https://docs.rs/permissions
- Size: 53.7 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# NOTE
If you want Windows support, check [faccess] instead.
# permissions
[![Crates.io](https://img.shields.io/crates/v/permissions.svg)](https://crates.io/crates/permissions)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/marcospb19/permissions/blob/main/LICENSE)
[![Docs.rs](https://docs.rs/permissions/badge.svg)](https://docs.rs/permissions)Useful filesystem queries for Unix file permissions:
See [`functions`](https://docs.rs/permissions/latest/permissions/functions/index.html).
- [`is_executable`](https://docs.rs/permissions/latest/permissions/functions/fn.is_executable.html)
- [`is_readable`](https://docs.rs/permissions/latest/permissions/functions/fn.is_readable.html)
- [`is_writable`](https://docs.rs/permissions/latest/permissions/functions/fn.is_writable.html)
- [`is_removable`](https://docs.rs/permissions/latest/permissions/functions/fn.is_removable.html)
- [`is_creatable`](https://docs.rs/permissions/latest/permissions/functions/fn.is_creatable.html)
- [`access_syscall`](https://docs.rs/permissions/latest/permissions/functions/fn.access_syscall.html) supports a custom bitfield of permissions.## Examples:
```rust
use permissions::*;fn main() -> std::io::Result<()> {
// Functions accept `AsRef`
assert!(is_readable("src/")?);
assert!(is_writable("src/")?);
assert!(is_writable("src/lib.rs")?);
assert!(is_executable("/usr/bin/cat")?);
assert!(is_removable("src/lib.rs")?);
assert!(is_creatable("src/file.rs")?);Ok(())
}
```# Alternatives
- [faccess] - it provides Windows support and a trait-based API.[faccess]: https://github.com/Freaky/faccess