Skip to content

Commit a767125

Browse files
committed
Use dirs-sys rather than copying in part of it.
1 parent 608b990 commit a767125

File tree

3 files changed

+36
-53
lines changed

3 files changed

+36
-53
lines changed

Cargo.lock

Lines changed: 34 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ license = "MIT"
1010
compresstimator = { git = "https://github.com/Freaky/compresstimator.git", rev = "26ddd3f499bc46f2c8b3ce814e9723ed41b47919" }
1111
crossbeam-channel = "0.3"
1212
ctrlc = "3.0"
13+
dirs-sys = "0.3.3"
1314
directories = "2.0.1"
1415
filesize = "0.1"
1516
fs2 = "0.4.3"

src/gui.rs

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use std::sync::Arc;
44

55
use crossbeam_channel::{bounded, Receiver};
66
use ctrlc;
7+
use dirs_sys::known_folder;
78
use serde_derive::{Deserialize, Serialize};
89
use serde_json;
910
use web_view::*;
@@ -314,26 +315,6 @@ fn program_files() -> PathBuf {
314315
known_folder(&knownfolders::FOLDERID_ProgramFiles).expect("Program files path")
315316
}
316317

317-
// stolen from directories crate
318-
// Copyright (c) 2018 directories-rs contributors
319-
// (MIT license)
320-
fn known_folder(folder_id: shtypes::REFKNOWNFOLDERID) -> Option<PathBuf> {
321-
unsafe {
322-
let mut path_ptr: winnt::PWSTR = std::ptr::null_mut();
323-
let result =
324-
shlobj::SHGetKnownFolderPath(folder_id, 0, std::ptr::null_mut(), &mut path_ptr);
325-
if result == winerror::S_OK {
326-
let len = winbase::lstrlenW(path_ptr) as usize;
327-
let path = std::slice::from_raw_parts(path_ptr, len);
328-
let ostr: std::ffi::OsString = std::os::windows::ffi::OsStringExt::from_wide(path);
329-
combaseapi::CoTaskMemFree(path_ptr as *mut winapi::ctypes::c_void);
330-
Some(PathBuf::from(ostr))
331-
} else {
332-
None
333-
}
334-
}
335-
}
336-
337318
use lazy_static::lazy_static;
338319
use std::sync::Mutex;
339320

0 commit comments

Comments
 (0)