mirror of
https://github.com/rust-lang/cargo
synced 2024-10-02 14:04:23 +00:00
more
This commit is contained in:
parent
f89e58f300
commit
bf10d8d36b
|
@ -2,7 +2,6 @@ use std::env;
|
|||
use std::ffi::OsString;
|
||||
use std::os::windows::ffi::OsStringExt;
|
||||
use std::path::PathBuf;
|
||||
use std::ptr;
|
||||
|
||||
use windows_sys::Win32::Foundation::{MAX_PATH, S_OK};
|
||||
use windows_sys::Win32::UI::Shell::{SHGetFolderPathW, CSIDL_PROFILE};
|
||||
|
@ -17,14 +16,8 @@ pub fn home_dir_inner() -> Option<PathBuf> {
|
|||
#[cfg(not(target_vendor = "uwp"))]
|
||||
fn home_dir_crt() -> Option<PathBuf> {
|
||||
unsafe {
|
||||
let mut path: Vec<u16> = Vec::with_capacity(MAX_PATH);
|
||||
match SHGetFolderPathW(
|
||||
ptr::null_mut(),
|
||||
CSIDL_PROFILE,
|
||||
ptr::null_mut(),
|
||||
0,
|
||||
path.as_mut_ptr(),
|
||||
) {
|
||||
let mut path: Vec<u16> = Vec::with_capacity(MAX_PATH as usize);
|
||||
match SHGetFolderPathW(0, CSIDL_PROFILE as i32, 0, 0, path.as_mut_ptr()) {
|
||||
S_OK => {
|
||||
let len = wcslen(path.as_ptr());
|
||||
path.set_len(len);
|
||||
|
|
Loading…
Reference in a new issue