Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ name: CI

on:
pull_request:
workflow_call:
branches:
- master

env:
CARGO_TERM_COLOR: always
Expand All @@ -11,17 +12,24 @@ jobs:
test:
name: test
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4

- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy

- 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

Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ permissions:
contents: write

jobs:
test:
uses: ./.github/workflows/ci.yml
build:
name: Build (${{ matrix.os }})
runs-on: ${{ matrix.os }}
Expand Down
27 changes: 16 additions & 11 deletions src/files/prelude.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -22,6 +23,7 @@ pub struct SaveScreenshotResult {
pub path_id: PathBuf,
pub error: Option<String>,
}

pub fn last_modified(path: &Path) -> std::io::Result<SystemTime> {
fs::metadata(path)?.modified()
}
Expand Down Expand Up @@ -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,<path> 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()?;
}

Expand Down
Loading