MCPcopy Index your code
hub / github.com/caffienerd/struct-cli / is_executable

Function is_executable

src/utils.rs:23–43  ·  view source on GitHub ↗

Check if a file is executable

(path: &Path)

Source from the content-addressed store, hash-verified

21
22/// Check if a file is executable
23pub fn is_executable(path: &Path) -> bool {
24 #[cfg(unix)]
25 {
26 use std::os::unix::fs::PermissionsExt;
27 if let Ok(metadata) = fs::metadata(path) {
28 let permissions = metadata.permissions();
29 return permissions.mode() & 0o111 != 0;
30 }
31 }
32
33 #[cfg(not(unix))]
34 {
35 // On Windows, check common executable extensions
36 if let Some(ext) = path.extension() {
37 let ext = ext.to_string_lossy().to_lowercase();
38 return matches!(ext.as_str(), "exe" | "bat" | "cmd" | "sh" | "py" | "ps1");
39 }
40 }
41
42 false
43}
44
45/// Get total size of a directory recursively
46pub fn get_dir_size(path: &Path) -> u64 {

Callers 3

display_file_summaryFunction · 0.85
display_treeFunction · 0.85
display_search_treeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected