From c3fc0813b9f08df7f6a0140eb81fde0fb23fb8b0 Mon Sep 17 00:00:00 2001 From: kirawi <67773714+kirawi@users.noreply.github.com> Date: Mon, 8 Jan 2024 18:15:16 -0500 Subject: [PATCH] fix ci --- helix-view/src/document.rs | 17 ----------------- helix-view/src/faccess.rs | 9 ++++++--- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index 3d73d5560fcb4..d3c3b54b0fbf0 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -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, diff --git a/helix-view/src/faccess.rs b/helix-view/src/faccess.rs index c28a8368c76f1..71800b88130d6 100644 --- a/helix-view/src/faccess.rs +++ b/helix-view/src/faccess.rs @@ -1,4 +1,4 @@ -//! From https://github.com/Freaky/faccess +//! From use std::io; use std::path::Path; @@ -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)?; @@ -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(()) } }