mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2026-01-16 18:21:01 +00:00
Merge pull request #2383 from tertsdiepraam/whoami/use-winapi
`whoami`: remove `advapi32-sys` dependency and use `winapi`
This commit is contained in:
commit
be9104b084
3 changed files with 2 additions and 14 deletions
|
|
@ -20,7 +20,6 @@ uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["
|
|||
uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" }
|
||||
|
||||
[target.'cfg(target_os = "windows")'.dependencies]
|
||||
advapi32-sys = "0.2.0"
|
||||
winapi = { version = "0.3", features = ["lmcons"] }
|
||||
|
||||
[[bin]]
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ extern crate winapi;
|
|||
|
||||
use self::winapi::shared::lmcons;
|
||||
use self::winapi::shared::minwindef;
|
||||
use self::winapi::um::winnt;
|
||||
use self::winapi::um::{winbase, winnt};
|
||||
use std::io::{Error, Result};
|
||||
use std::mem;
|
||||
use uucore::wide::FromWide;
|
||||
|
|
@ -20,7 +20,7 @@ pub unsafe fn get_username() -> Result<String> {
|
|||
#[allow(deprecated)]
|
||||
let mut buffer: [winnt::WCHAR; lmcons::UNLEN as usize + 1] = mem::uninitialized();
|
||||
let mut len = buffer.len() as minwindef::DWORD;
|
||||
if advapi32::GetUserNameW(buffer.as_mut_ptr(), &mut len) == 0 {
|
||||
if winbase::GetUserNameW(buffer.as_mut_ptr(), &mut len) == 0 {
|
||||
return Err(Error::last_os_error());
|
||||
}
|
||||
let username = String::from_wide(&buffer[..len as usize - 1]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue