diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aa10f0e..822a0b2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,8 @@ name: CI on: pull_request: - workflow_call: + branches: + - master env: CARGO_TERM_COLOR: always @@ -11,8 +12,10 @@ jobs: test: name: test runs-on: ubuntu-22.04 + steps: - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable with: components: rustfmt, clippy @@ -20,8 +23,13 @@ jobs: - name: Install Linux system dependencies run: | sudo apt-get update - sudo apt-get install -y pkg-config libxcb-shape0-dev libxcb-xfixes0-dev \ - libxkbcommon-dev libxkbcommon-x11-dev libfontconfig1-dev + sudo apt-get install -y \ + pkg-config \ + libxcb-shape0-dev \ + libxcb-xfixes0-dev \ + libxkbcommon-dev \ + libxkbcommon-x11-dev \ + libfontconfig1-dev - uses: Swatinem/rust-cache@v2 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fe3ec74..1c08839 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,8 +9,6 @@ permissions: contents: write jobs: - test: - uses: ./.github/workflows/ci.yml build: name: Build (${{ matrix.os }}) runs-on: ${{ matrix.os }} diff --git a/src/files/prelude.rs b/src/files/prelude.rs index 824bc22..f365884 100644 --- a/src/files/prelude.rs +++ b/src/files/prelude.rs @@ -1,6 +1,7 @@ use std::io::Read; use std::path::{Path, PathBuf}; use std::{fs, time::SystemTime}; +use std::{io, process::Command}; use crate::config::ImageFormat; use crate::config::project_settings_data::ProjectSettingsData; @@ -22,6 +23,7 @@ pub struct SaveScreenshotResult { pub path_id: PathBuf, pub error: Option, } + pub fn last_modified(path: &Path) -> std::io::Result { fs::metadata(path)?.modified() } @@ -428,32 +430,35 @@ pub(super) fn glob_to_regex(pattern: &str) -> String { regex } -pub fn open_in_file_explorer(path: &Path) -> std::io::Result<()> { +pub fn open_in_file_explorer(path: &Path) -> io::Result<()> { + if !path.exists() { + return Err(io::Error::new( + io::ErrorKind::NotFound, + format!("Path does not exist: {}", path.display()), + )); + } + #[cfg(target_os = "windows")] { - // /select, highlights the file itself instead of just opening the folder - Command::new("explorer") - .args(["/select,", &path.to_string_lossy()]) - .spawn()?; + // explorer.exe expects /select, as ONE argument. + let argument = format!("/select,{}", path.display()); + + Command::new("explorer.exe").arg(argument).spawn()?; } #[cfg(target_os = "macos")] { - Command::new("open") - .args(["-R", &path.to_string_lossy()]) - .spawn()?; + Command::new("open").args(["-R"]).arg(path).spawn()?; } #[cfg(target_os = "linux")] { - // Linux has no universal "reveal and select" — fall back to opening the containing folder - - use std::process::Command; let dir = if path.is_dir() { path } else { path.parent().unwrap_or(path) }; + Command::new("xdg-open").arg(dir).spawn()?; }