Hopefully fix desktop path resolution
This commit is contained in:
parent
bc44b249f4
commit
1c798dbcae
|
@ -135,6 +135,26 @@ version = "0.8.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"
|
||||
|
||||
[[package]]
|
||||
name = "dirs"
|
||||
version = "4.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059"
|
||||
dependencies = [
|
||||
"dirs-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs-sys"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"redox_users",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "encoding_rs"
|
||||
version = "0.8.31"
|
||||
|
@ -223,6 +243,17 @@ dependencies = [
|
|||
"pin-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"wasi 0.10.2+wasi-snapshot-preview1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gimli"
|
||||
version = "0.26.1"
|
||||
|
@ -510,7 +541,7 @@ checksum = "713d550d9b44d89174e066b7a6217ae06234c10cb47819a88290d2b353c31799"
|
|||
dependencies = [
|
||||
"libc",
|
||||
"log",
|
||||
"wasi",
|
||||
"wasi 0.11.0+wasi-snapshot-preview1",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
|
@ -711,6 +742,17 @@ dependencies = [
|
|||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_users"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"redox_syscall",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.5.6"
|
||||
|
@ -799,6 +841,7 @@ dependencies = [
|
|||
name = "school-computer-toolkit"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dirs",
|
||||
"miette",
|
||||
"ramhorns",
|
||||
"reqwest",
|
||||
|
@ -1184,6 +1227,12 @@ dependencies = [
|
|||
"try-lock",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.10.2+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.11.0+wasi-snapshot-preview1"
|
||||
|
|
|
@ -6,6 +6,7 @@ edition = "2021"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
dirs = "4"
|
||||
miette = { version = "4.7", features = [ "fancy" ] }
|
||||
ramhorns = "0.14"
|
||||
reqwest = { version = "0.11.10", features = [ "json" ] }
|
||||
|
|
12
src/main.rs
12
src/main.rs
|
@ -19,7 +19,13 @@ pub fn swtools_path() -> &'static Path {
|
|||
}
|
||||
|
||||
pub fn desktop_path() -> PathBuf {
|
||||
Path::new("H:\\Profile\\Desktop").to_owned()
|
||||
let mut dir = dirs::home_dir()
|
||||
.expect("Could not find your home directory.")
|
||||
.join("Desktop");
|
||||
if !dir.exists() {
|
||||
dir = Path::new("H:\\Profile\\Desktop").to_owned();
|
||||
}
|
||||
dir
|
||||
}
|
||||
|
||||
pub struct Context {
|
||||
|
@ -38,6 +44,10 @@ async fn main() -> Result<()> {
|
|||
bail!("Could not find or access {}", SWTOOLS_PATH);
|
||||
}
|
||||
|
||||
if !desktop_path().exists() {
|
||||
bail!("Could not find your desktop directory.");
|
||||
}
|
||||
|
||||
let nppp_zip = swtools_path().join("temp").join("notepad-plus-plus.zip");
|
||||
let nppp_dir = swtools_path().join("notepad-plus-plus");
|
||||
|
||||
|
|
Loading…
Reference in New Issue