Skip to content

Commit bf10d8d

Browse files
committed
more
1 parent f89e58f commit bf10d8d

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

crates/home/src/windows.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use std::env;
22
use std::ffi::OsString;
33
use std::os::windows::ffi::OsStringExt;
44
use std::path::PathBuf;
5-
use std::ptr;
65

76
use windows_sys::Win32::Foundation::{MAX_PATH, S_OK};
87
use windows_sys::Win32::UI::Shell::{SHGetFolderPathW, CSIDL_PROFILE};
@@ -17,14 +16,8 @@ pub fn home_dir_inner() -> Option<PathBuf> {
1716
#[cfg(not(target_vendor = "uwp"))]
1817
fn home_dir_crt() -> Option<PathBuf> {
1918
unsafe {
20-
let mut path: Vec<u16> = Vec::with_capacity(MAX_PATH);
21-
match SHGetFolderPathW(
22-
ptr::null_mut(),
23-
CSIDL_PROFILE,
24-
ptr::null_mut(),
25-
0,
26-
path.as_mut_ptr(),
27-
) {
19+
let mut path: Vec<u16> = Vec::with_capacity(MAX_PATH as usize);
20+
match SHGetFolderPathW(0, CSIDL_PROFILE as i32, 0, 0, path.as_mut_ptr()) {
2821
S_OK => {
2922
let len = wcslen(path.as_ptr());
3023
path.set_len(len);

0 commit comments

Comments
 (0)