From 5dad532a43621e2354069aba7d747b1325b1c643 Mon Sep 17 00:00:00 2001 From: Marcin Mielniczuk Date: Mon, 7 Oct 2019 16:25:20 +0200 Subject: [PATCH] Use cvt from the cvt crate in winx --- winx/Cargo.toml | 1 + winx/src/file.rs | 10 +--------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/winx/Cargo.toml b/winx/Cargo.toml index cb75e33f04..7b41eb56b9 100644 --- a/winx/Cargo.toml +++ b/winx/Cargo.toml @@ -9,3 +9,4 @@ description = "Windows API helper library" [dependencies] winapi = { version = "0.3", features = ["std", "errhandlingapi", "handleapi", "processthreadsapi", "securitybaseapi", "winbase", "winerror", "ws2def", "fileapi", "aclapi" ] } bitflags = "1.0" +cvt = "0.1" diff --git a/winx/src/file.rs b/winx/src/file.rs index 5e42f6f4a0..dc04dcfb96 100644 --- a/winx/src/file.rs +++ b/winx/src/file.rs @@ -1,5 +1,6 @@ #![allow(non_camel_case_types)] use crate::{winerror, Result}; +use cvt::cvt; use std::ffi::{c_void, OsString}; use std::fs::File; use std::io; @@ -380,15 +381,6 @@ pub fn get_file_path(file: &File) -> Result { Ok(OsString::from_wide(written_bytes)) } -// Taken from Rust libstd, file libstd/sys/windows/fs.rs -fn cvt(i: winapi::shared::minwindef::BOOL) -> io::Result<()> { - if i == 0 { - Err(io::Error::last_os_error()) - } else { - Ok(()) - } -} - pub fn get_fileinfo(file: &File) -> io::Result { use fileapi::{GetFileInformationByHandle, BY_HANDLE_FILE_INFORMATION}; use std::mem;