Skip to content

Commit

Permalink
fix(cli): smarter windows path resolution
Browse files Browse the repository at this point in the history
This commit improves Windows path resolution so that when people run the
ahk-asc command with "applications.yaml" as an argument, without having
".\" prepended, the command will still succeed as expected.

fix #192
  • Loading branch information
LGUG2Z committed Jul 28, 2022
1 parent f8cf70e commit 763c710
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions komorebic/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1293,15 +1293,18 @@ fn resolve_windows_path(raw_path: &str) -> Result<PathBuf> {
.parent()
.ok_or_else(|| anyhow!("cannot parse directory"))?;

let file = full_path
.components()
.last()
.ok_or_else(|| anyhow!("cannot parse filename"))?;

let mut canonicalized = std::fs::canonicalize(parent)?;
canonicalized.push(file);

Ok(canonicalized)
Ok(if parent.is_dir() {
let file = full_path
.components()
.last()
.ok_or_else(|| anyhow!("cannot parse filename"))?;

let mut canonicalized = std::fs::canonicalize(parent)?;
canonicalized.push(file);
canonicalized
} else {
full_path
})
}

fn show_window(hwnd: HWND, command: SHOW_WINDOW_CMD) {
Expand Down

0 comments on commit 763c710

Please sign in to comment.