Skip to content

Commit

Permalink
Remove usage of kernel32-sys crate
Browse files Browse the repository at this point in the history
  • Loading branch information
tesuji authored and froydnj committed Jun 24, 2019
1 parent e516d90 commit 5855673
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 17 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,17 @@ daemonize = "0.3"
tokio-uds = "0.2"

[target.'cfg(windows)'.dependencies]
kernel32-sys = "0.2.2"
winapi = { version = "0.3", features = ["winnls"] }
tokio-named-pipes = "0.1"
tokio-reactor = "0.1"

[target.'cfg(windows)'.dependencies.winapi]
version = "0.3"
features = [
"fileapi",
"handleapi",
"winnls",
]

[features]
default = ["dist-client", "s3"]
all = ["dist-client", "redis", "s3", "memcached", "gcs", "azure"]
Expand Down
5 changes: 3 additions & 2 deletions src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ fn run_server_process() -> Result<ServerStartup> {
use winapi::um::winbase::{
CREATE_NEW_PROCESS_GROUP, CREATE_UNICODE_ENVIRONMENT, DETACHED_PROCESS,
};
use winapi::um::handleapi::CloseHandle;

trace!("run_server_process");

Expand Down Expand Up @@ -231,8 +232,8 @@ fn run_server_process() -> Result<ServerStartup> {
) == TRUE
} {
unsafe {
kernel32::CloseHandle(pi.hProcess);
kernel32::CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
}
} else {
return Err(io::Error::last_os_error().into());
Expand Down
17 changes: 7 additions & 10 deletions src/compiler/msvc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,25 +429,22 @@ pub fn parse_arguments(arguments: &[OsString], cwd: &Path, is_clang: bool) -> Co
#[cfg(windows)]
fn normpath(path: &str) -> String {
use std::os::windows::ffi::OsStringExt;
use std::ptr;
use std::os::windows::io::AsRawHandle;
use std::ptr;
use winapi::um::fileapi::GetFinalPathNameByHandleW;
File::open(path)
.and_then(|f| {
let handle = f.as_raw_handle();
let size = unsafe { kernel32::GetFinalPathNameByHandleW(handle,
ptr::null_mut(),
0,
0)
};
let size = unsafe { GetFinalPathNameByHandleW(handle, ptr::null_mut(), 0, 0) };
if size == 0 {
return Err(io::Error::last_os_error());
}
let mut wchars = Vec::with_capacity(size as usize);
wchars.resize(size as usize, 0);
if unsafe { kernel32::GetFinalPathNameByHandleW(handle,
wchars.as_mut_ptr(),
wchars.len() as u32,
0) } == 0 {
if unsafe {
GetFinalPathNameByHandleW(handle, wchars.as_mut_ptr(), wchars.len() as u32, 0)
} == 0
{
return Err(io::Error::last_os_error());
}
// The return value of GetFinalPathNameByHandleW uses the
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1525,9 +1525,9 @@ impl OutputsRewriter for RustOutputsRewriter {
#[test]
#[cfg(all(feature = "dist-client", target_os = "windows"))]
fn test_rust_outputs_rewriter() {
use compiler::compiler::OutputsRewriter;
use crate::compiler::compiler::OutputsRewriter;
use std::io::Write;
use test::utils::create_file;
use crate::test::utils::create_file;

let mut pt = dist::PathTransformer::new();
pt.to_dist(Path::new("c:\\")).unwrap();
Expand Down

0 comments on commit 5855673

Please sign in to comment.