Skip to content

Conversation

@Quackdoc
Copy link
Contributor

Currently windows compilation is broken, the current state of this is just enough to actually get cosmic-files to load on windows again. I plan on cleaning up the added crap and mangled commits later.

  • rustembed which is used for localization breaks when cross compiling, the compile works but the resulting binary is unusable. Not a major issue.
  • xdg-mime is patched to allow compilation on windows, There are a few routes forwards here but I think the best one is to use an alternative mime provider on windows or try to add support for embedded mime. XDG mime on windows is possible, and an installer might be able to make this work. Without mime support 90% of stuff is unusable so this is a major issue.
  • default features are obviously not compatible with windows.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually have a WIP patch for this section, but I don't have a Windows machine to test it out on. Would you be able to see if this works?

diff --git a/src/archive.rs b/src/archive.rs
index a38ac83..3141568 100644
--- a/src/archive.rs
+++ b/src/archive.rs
@@ -185,19 +185,15 @@ fn zip_extract<R: io::Read + io::Seek, P: AsRef<Path>>(
             #[cfg(windows)]
             {
                 let Ok(target) = String::from_utf8(target) else {
-                    return Err(ZipError::InvalidArchive("Invalid UTF-8 as symlink target"));
+                    return Err(ZipError::InvalidArchive(
+                        "Invalid UTF-8 as symlink target".into(),
+                    ));
                 };
                 let target = target.into_boxed_str();
                 let target_is_dir_from_archive =
-                    archive.shared.files.contains_key(&target) && is_dir(&target);
-                let target_path = directory.as_ref().join(OsString::from(target.to_string()));
-                let target_is_dir = if target_is_dir_from_archive {
-                    true
-                } else if let Ok(meta) = std::fs::metadata(&target_path) {
-                    meta.is_dir()
-                } else {
-                    false
-                };
+                    archive.by_name(&target).is_ok_and(|file| file.is_dir());
+                let target_path = directory.as_ref().join(target.as_ref());
+                let target_is_dir = target_is_dir_from_archive || target_path.is_dir();
                 if target_is_dir {
                     std::os::windows::fs::symlink_dir(target_path, outpath.as_path())?;
                 } else {

@Cheong-Lau
Copy link
Contributor

As for xdg_mime, the icons you could probably get using the Windows API, and the Mime type using mime_guess. But that's a lot of code you'd need to replace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants