Skip to content

Commit

Permalink
fix macos build
Browse files Browse the repository at this point in the history
  • Loading branch information
kamiyaa committed Sep 27, 2024
1 parent af643db commit b0fb708
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/commands/bulk_rename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub fn _bulk_rename(app_state: &mut AppState) -> AppResult {
let file_name = path.file_name();
let file_name_as_bytes = file_name.as_bytes();
file.write_all(file_name_as_bytes)?;
file.write_all(&[b'\n'])?;
file.write_all(b"\n")?;
}
}

Expand Down
8 changes: 8 additions & 0 deletions src/fs/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ use std::{fs, io, path, time};

use nix::sys::stat::{Mode, SFlag};

#[cfg(target_os = "macos")]
use nix::sys::stat::mode_t;

#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum FileType {
Directory,
Expand Down Expand Up @@ -77,7 +80,12 @@ impl JoshutoMetadata {
let (file_type, mode) = match metadata.as_ref() {
Ok(metadata) => {
let metadata_mode = metadata.mode();
#[cfg(target_os = "macos")]
let sflag = SFlag::from_bits_truncate(metadata_mode as mode_t);

#[cfg(not(target_os = "macos"))]
let sflag = SFlag::from_bits_truncate(metadata_mode);

let mode = Mode::from_bits_truncate(metadata_mode);
(FileType::from_mode(sflag), mode)
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/name_resolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub fn rename_filename_conflict(path: &mut path::PathBuf) {
path.pop();

let mut file_name = file_name.clone();
file_name.push(&format!("_{}", i));
file_name.push(format!("_{i}"));
path.push(file_name);
}
}

0 comments on commit b0fb708

Please sign in to comment.