Skip to content

Commit

Permalink
use platform specific file permissions API
Browse files Browse the repository at this point in the history
  • Loading branch information
Timmoth committed Oct 20, 2024
1 parent 48d82f0 commit f413b01
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/file_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ use std::path::Path;
use std::time::UNIX_EPOCH;
use time::OffsetDateTime;

#[cfg(unix)]
use std::os::unix::fs::PermissionsExt;

pub fn file_info(file_path: String) {
let path = Path::new(file_path.as_str());
let path = Path::new(&file_path);

// Check if file exists
if !path.exists() {
Expand Down Expand Up @@ -89,7 +92,7 @@ pub fn md5_checksum(file_path: String) {
}

let md5_result = md5_hasher.finalize();
println!("{:x}", md5_result);
println!("MD5: {:x}", md5_result);
}

pub fn sha1_checksum(file_path: String) {
Expand All @@ -109,7 +112,7 @@ pub fn sha1_checksum(file_path: String) {
}

let sha1_result = sha1_hasher.finalize();
println!("{:x}", sha1_result);
println!("SHA-1: {:x}", sha1_result);
}

pub fn sha256_checksum(file_path: String) {
Expand All @@ -129,5 +132,5 @@ pub fn sha256_checksum(file_path: String) {
}

let sha256_result = sha256_hasher.finalize();
println!("{:x}", sha256_result);
}
println!("SHA-256: {:x}", sha256_result);
}

0 comments on commit f413b01

Please sign in to comment.