summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/types.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/types.rs b/src/types.rs
index b20ada1..f0cbfd4 100644
--- a/src/types.rs
+++ b/src/types.rs
@@ -71,4 +71,25 @@ impl AppImage {
Ok(())
}
+ pub async fn create_symlink(&self) -> Result<(), Box<dyn std::error::Error>> {
+ let home = std::env::var("HOME")?;
+ let local_bin = PathBuf::from(home).join(".local/bin");
+
+ fs::create_dir_all(&local_bin).await?;
+
+ let symlink_path = local_bin.join(&self.executable);
+
+ #[cfg(unix)]
+ {
+ use tokio::fs;
+
+ if symlink_path.exists() {
+ fs::remove_file(&symlink_path).await?;
+ }
+
+ std::os::unix::fs::symlink(&self.file_path, &symlink_path)?;
+ }
+
+ Ok(())
+ }
}