https://github.com/fitzgen/is_executable
Is there an executable file at the given path?
https://github.com/fitzgen/is_executable
Last synced: 9 months ago
JSON representation
Is there an executable file at the given path?
- Host: GitHub
- URL: https://github.com/fitzgen/is_executable
- Owner: fitzgen
- License: apache-2.0
- Created: 2017-09-20T21:42:57.000Z (almost 9 years ago)
- Default Branch: main
- Last Pushed: 2025-08-25T18:33:57.000Z (11 months ago)
- Last Synced: 2025-10-05T00:32:10.187Z (9 months ago)
- Language: Rust
- Size: 33.2 KB
- Stars: 23
- Watchers: 1
- Forks: 10
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# `is_executable`
Is there an executable file at the given path?
[](https://docs.rs/is_executable/) [ ](https://crates.io/crates/is_executable) [](https://github.com/fitzgen/is_executable/actions/workflows/ci.yml)
A small helper function which determines whether or not the given path points to
an executable file. If there is no file at the given path, or the file is not
executable, then `false` is returned. When there is a file and the file is
executable, then `true` is returned.
This crate works on both Unix-based operating systems (macOS, Linux, FreeBSD,
etc...) and Windows.
Does not help with [time-of-check to time-of use
(TOCTOU)](https://en.wikipedia.org/wiki/Time-of-check_to_time-of-use) races.
The API comes in two flavors:
1. An extension trait to add an `is_executable` method on `std::path::Path`:
```rust
use std::path::Path;
use is_executable::IsExecutable;
fn main() {
let path = Path::new("some/path/to/a/file");
// Determine if `path` is executable.
if path.is_executable() {
println!("The path is executable!");
} else {
println!("The path is _not_ executable!");
}
}
```
2. For convenience, a standalone `is_executable` function, which takes any
`AsRef`:
```rust
use std::path::Path;
use is_executable::is_executable;
fn main() {
let path = Path::new("some/path/to/a/file");
// Determine if `path` is executable.
if is_executable(&path) {
println!("The path is executable!");
} else {
println!("The path is _not_ executable!");
}
}
```
License: Apache-2.0/MIT