#executable #path #file #permissions

is_executable

Is there an executable file at the given path?

3 releases (1 stable)

Uses old Rust 2015

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

#24 in Filesystem

Download history 3740/week @ 2020-10-02 3320/week @ 2020-10-09 2789/week @ 2020-10-16 3168/week @ 2020-10-23 3002/week @ 2020-10-30 3910/week @ 2020-11-06 2665/week @ 2020-11-13 3476/week @ 2020-11-20 5741/week @ 2020-11-27 5280/week @ 2020-12-04 5332/week @ 2020-12-11 4375/week @ 2020-12-18 4127/week @ 2020-12-25 6330/week @ 2021-01-01 6900/week @ 2021-01-08 4878/week @ 2021-01-15

18,075 downloads per month
Used in 28 crates (18 directly)

Apache-2.0/MIT

10KB
67 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

~27KB