4 个版本 (2 个稳定版)

使用旧的 Rust 2015

1.0.1 2021年2月8日
1.0.0 2021年1月11日
0.1.2 2019年1月16日
0.1.0 2017年9月20日

#150 in 文件系统

Download history · Rust 包仓库 64042/week @ 2024-03-14 · Rust 包仓库 68160/week @ 2024-03-21 · Rust 包仓库 67939/week @ 2024-03-28 · Rust 包仓库 75146/week @ 2024-04-04 · Rust 包仓库 69816/week @ 2024-04-11 · Rust 包仓库 67807/week @ 2024-04-18 · Rust 包仓库 62794/week @ 2024-04-25 · Rust 包仓库 60630/week @ 2024-05-02 · Rust 包仓库 58608/week @ 2024-05-09 · Rust 包仓库 61016/week @ 2024-05-16 · Rust 包仓库 69389/week @ 2024-05-23 · Rust 包仓库 68930/week @ 2024-05-30 · Rust 包仓库 63284/week @ 2024-06-06 · Rust 包仓库 66626/week @ 2024-06-13 · Rust 包仓库 65091/week @ 2024-06-20 · Rust 包仓库 51581/week @ 2024-06-27 · Rust 包仓库

每月下载量 257,974
160 个 Crates (71 直接) 使用

Apache-2.0/MIT 许可

10KB
81

Build Status

is_executable

给定路径处是否存在可执行文件?

Unix Build Status Windows Build Status

一个小型辅助函数,用于确定给定路径是否指向一个可执行文件。如果给定路径不存在文件,或者文件不可执行,则返回 false。如果文件存在且可执行,则返回 true

该库在基于 Unix 的操作系统(mac、linux、freebsd 等)和 Windows 上都有效。

API 有两种形式

  1. 一个扩展 trait,用于在 std::path::Path 上添加 is_executable 方法

    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. 为了方便,一个独立的 is_executable 函数,它接受任何 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!");
        }
    }
    

许可:Apache-2.0/MIT

依赖项

~175KB