mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-04-29 12:06:01 +02:00
use dunce
This commit is contained in:
@@ -37,6 +37,7 @@ regex = "1"
|
||||
open = { version = "5", features = ["shellexecute-on-windows"] }
|
||||
encoding_rs = "0.8"
|
||||
os_pipe = "1"
|
||||
dunce = { workspace = true }
|
||||
|
||||
[target."cfg(windows)".dependencies.windows]
|
||||
version = "0.54"
|
||||
|
||||
@@ -139,10 +139,11 @@ pub fn open<P: AsRef<str>>(scope: &OpenScope, path: P, with: Option<Program>) ->
|
||||
|
||||
pub fn show_item_in_directory<P: AsRef<std::path::Path>>(p: P) -> crate::Result<()> {
|
||||
let p = p.as_ref().canonicalize()?;
|
||||
let p = dunce::simplified(&p);
|
||||
|
||||
#[cfg(any(
|
||||
windows,
|
||||
target_os = "maco",
|
||||
target_os = "macos",
|
||||
target_os = "linux",
|
||||
target_os = "dragonfly",
|
||||
target_os = "freebsd",
|
||||
@@ -153,7 +154,7 @@ pub fn show_item_in_directory<P: AsRef<std::path::Path>>(p: P) -> crate::Result<
|
||||
|
||||
#[cfg(not(any(
|
||||
windows,
|
||||
target_os = "maco",
|
||||
target_os = "macos",
|
||||
target_os = "linux",
|
||||
target_os = "dragonfly",
|
||||
target_os = "freebsd",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use std::{ffi::OsString, path::PathBuf};
|
||||
use std::path::Path;
|
||||
|
||||
use windows::{
|
||||
core::{w, HSTRING, PCWSTR},
|
||||
@@ -12,18 +12,16 @@ use windows::{
|
||||
},
|
||||
};
|
||||
|
||||
pub fn show_item_in_directory(file: PathBuf) -> crate::Result<()> {
|
||||
pub fn show_item_in_directory(file: &Path) -> crate::Result<()> {
|
||||
let _ = unsafe { CoInitialize(None) };
|
||||
|
||||
let dir = file
|
||||
.parent()
|
||||
.ok_or_else(|| crate::Error::NoParent(file.clone()))?;
|
||||
.ok_or_else(|| crate::Error::NoParent(file.to_path_buf()))?;
|
||||
|
||||
let dir = OsString::from(dir);
|
||||
let dir = HSTRING::from(dir);
|
||||
let dir_item = unsafe { ILCreateFromPathW(PCWSTR::from_raw(dir.as_ptr())) };
|
||||
|
||||
let file = OsString::from(file);
|
||||
let file = HSTRING::from(file);
|
||||
let file_item = unsafe { ILCreateFromPathW(PCWSTR::from_raw(file.as_ptr())) };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user