Skip to content

Commit

Permalink
fix ci
Browse files Browse the repository at this point in the history
  • Loading branch information
kirawi committed Jan 8, 2024
1 parent 9972882 commit c3fc081
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
17 changes: 0 additions & 17 deletions helix-view/src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -988,23 +988,6 @@ impl Document {
};
}

#[cfg(not(unix))]
// Detect if the file is readonly and change the readonly field if necessary (non-unix os)
pub fn detect_readonly(&mut self) {
// TODO Use the Windows' function `CreateFileW` to check if a file is readonly
// Discussion: https://github.com/helix-editor/helix/pull/7740#issuecomment-1656806459
// Vim implementation: https://github.com/vim/vim/blob/4c0089d696b8d1d5dc40568f25ea5738fa5bbffb/src/os_win32.c#L7665
// Windows binding: https://microsoft.github.io/windows-docs-rs/doc/windows/Win32/Storage/FileSystem/fn.CreateFileW.html
self.readonly = match &self.path {
None => false,
Some(p) => match std::fs::metadata(p) {
Err(err) if err.kind() == std::io::ErrorKind::NotFound => false,
Err(_) => false,
Ok(metadata) => metadata.permissions().readonly(),
},
};
}

/// Reload the document from its path.
pub fn reload(
&mut self,
Expand Down
9 changes: 6 additions & 3 deletions helix-view/src/faccess.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! From https://github.com/Freaky/faccess
//! From <https://github.com/Freaky/faccess>

use std::io;
use std::path::Path;
Expand Down Expand Up @@ -66,7 +66,7 @@ mod imp {
chown(to, Some(uid), Some(gid))?;

let mut perms = meta.permissions();
let new_perms = (perms.mode() & 0x0707) | (perms.mode() & 0x07) << 3;
let new_perms = (perms.mode() & 0o0707) | (perms.mode() & 0o07) << 3;
perms.set_mode(new_perms);

std::fs::set_permissions(to, perms)?;
Expand Down Expand Up @@ -436,7 +436,10 @@ mod imp {
}

pub fn copy_metadata(_from: &path, _to: &Path) -> std::io::Result<()> {
// Not possible
let meta = std::fs::File::open(from)?.metadata()?;
let perms = meta.permissions();
std::fs::set_permissions(to, perms)?;

Ok(())
}
}
Expand Down

0 comments on commit c3fc081

Please sign in to comment.