4 releases (2 stable)

Uses old Rust 2015

1.0.1 Feb 8, 2021
1.0.0 Jan 11, 2021
0.1.2 Jan 16, 2019
0.1.0 Sep 20, 2017

#110 in Filesystem

Download history 58452/week @ 2023-12-11 56715/week @ 2023-12-18 30211/week @ 2023-12-25 44799/week @ 2024-01-01 55584/week @ 2024-01-08 66554/week @ 2024-01-15 65742/week @ 2024-01-22 66356/week @ 2024-01-29 61407/week @ 2024-02-05 63026/week @ 2024-02-12 68543/week @ 2024-02-19 69434/week @ 2024-02-26 63310/week @ 2024-03-04 68828/week @ 2024-03-11 64990/week @ 2024-03-18 59367/week @ 2024-03-25

260,147 downloads per month
Used in 147 crates (67 directly)

Apache-2.0/MIT

10KB
81 lines

Build Status

is_executable

Is there an executable file at the given path?

Unix Build Status Windows Build Status

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 (mac, linux, freebsd, etc.) and Windows.

The API comes in two flavors:

  1. An extension trait to add an is_executable method on std::path::Path:

    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<Path>:

    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

Dependencies

~175KB