Auto merge of #31557 - retep998:house-directory, r=alexcrichton
This is the simple solution. I know @nodakai was working on a more complex solution that overhauled the `fill_utf16_buf` stuff. r? @alexcrichton
This commit is contained in:
@@ -338,9 +338,9 @@ pub fn home_dir() -> Option<PathBuf> {
|
|||||||
let _handle = Handle::new(token);
|
let _handle = Handle::new(token);
|
||||||
super::fill_utf16_buf(|buf, mut sz| {
|
super::fill_utf16_buf(|buf, mut sz| {
|
||||||
match c::GetUserProfileDirectoryW(token, buf, &mut sz) {
|
match c::GetUserProfileDirectoryW(token, buf, &mut sz) {
|
||||||
0 if c::GetLastError() != 0 => 0,
|
0 if c::GetLastError() != c::ERROR_INSUFFICIENT_BUFFER => 0,
|
||||||
0 => sz,
|
0 => sz,
|
||||||
n => n as c::DWORD,
|
_ => sz - 1, // sz includes the null terminator
|
||||||
}
|
}
|
||||||
}, super::os2path).ok()
|
}, super::os2path).ok()
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user