Skip to content

Commit 082e22e

Browse files
committed
Migrate remaining known-folders usage to windows
This replaces the remaining calls to the `get_known_folder_path` function provided by the `known-folders` crate to use the test helper `get_known_folder_path_with_flag` instead. (That helper uses the `windows` crate.) This change removes the dependency on `known-folders`, and also makes clearer how the different known folder path retrievals work differently, with one passing `KF_FLAG_DONT_VERIFY` and all the others passing `KF_FLAG_DEFAULT`.
1 parent 998fb48 commit 082e22e

File tree

3 files changed

+7
-16
lines changed

3 files changed

+7
-16
lines changed

Cargo.lock

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

gix-path/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ gix-testtools = { path = "../tests/tools" }
2929
serial_test = { version = "3.1.0", default-features = false }
3030

3131
[target.'cfg(windows)'.dev-dependencies]
32-
known-folders = "1.3.1"
3332
windows = { version = "0.61.3", features = [
3433
"Win32_System_Com",
3534
"Win32_System_Threading",

gix-path/src/env/git/tests.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,17 @@ mod locations {
99
path::{Path, PathBuf},
1010
};
1111

12-
use known_folders::{get_known_folder_path, KnownFolder};
1312
use windows::{
1413
core::{Result as WindowsResult, BOOL, GUID, PWSTR},
1514
Win32::{
1615
System::{
1716
Com::CoTaskMemFree,
1817
Threading::{GetCurrentProcess, IsWow64Process},
1918
},
20-
UI::Shell::{FOLDERID_UserProgramFiles, SHGetKnownFolderPath, KF_FLAG_DONT_VERIFY, KNOWN_FOLDER_FLAG},
19+
UI::Shell::{
20+
FOLDERID_LocalAppData, FOLDERID_ProgramFiles, FOLDERID_ProgramFilesX86, FOLDERID_UserProgramFiles,
21+
SHGetKnownFolderPath, KF_FLAG_DEFAULT, KF_FLAG_DONT_VERIFY, KNOWN_FOLDER_FLAG,
22+
},
2123
},
2224
};
2325
use winreg::{
@@ -486,10 +488,10 @@ mod locations {
486488
/// [known-folders]: https://learn.microsoft.com/en-us/windows/win32/shell/known-folders
487489
/// [knownfolderid]: https://learn.microsoft.com/en-us/windows/win32/shell/knownfolderid#remarks
488490
fn obtain_envlessly() -> Self {
489-
let pf_current = get_known_folder_path(KnownFolder::ProgramFiles)
491+
let pf_current = get_known_folder_path_with_flag(FOLDERID_ProgramFiles, KF_FLAG_DEFAULT)
490492
.expect("The process architecture specific program files folder is always available");
491493

492-
let pf_x86 = get_known_folder_path(KnownFolder::ProgramFilesX86)
494+
let pf_x86 = get_known_folder_path_with_flag(FOLDERID_ProgramFilesX86, KF_FLAG_DEFAULT)
493495
.expect("The x86 program files folder will in practice always be available");
494496

495497
let maybe_pf_64bit = RegKey::predef(HKEY_LOCAL_MACHINE)
@@ -579,7 +581,7 @@ mod locations {
579581
}
580582

581583
fn validate_user_folder(&self) {
582-
let expected = get_known_folder_path(KnownFolder::LocalAppData)
584+
let expected = get_known_folder_path_with_flag(FOLDERID_LocalAppData, KF_FLAG_DEFAULT)
583585
.expect("The user's local application data directory is available")
584586
.join("Programs");
585587
assert_eq!(

0 commit comments

Comments
 (0)