Update windows ffi bindings

This commit is contained in:
Chris Denton 2023-08-16 09:18:34 +01:00
parent 9f48a85447
commit d9c85daa51
No known key found for this signature in database
GPG Key ID: 713472F2F45627DE
7 changed files with 104 additions and 127 deletions

View File

@ -5851,19 +5851,21 @@ dependencies = [
[[package]]
name = "windows-bindgen"
version = "0.49.0"
version = "0.51.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6935fb09b84ee57929ae92518b475f5dfdfbeb87c5334756acc28ee8e202b60"
checksum = "bc1f16b778125675feee0d15d6dd9f6af0e3ac52b3233d63a10aa39230c1cd75"
dependencies = [
"proc-macro2",
"rayon",
"syn 2.0.27",
"windows-metadata",
"windows-tokens",
]
[[package]]
name = "windows-metadata"
version = "0.49.0"
version = "0.51.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f5bca94a32bf1e6a376522b6601275a3b611ee885ec0f1b6a05f17e8cfd3385"
checksum = "753135d996f9da437c0b31dbde3032489a61708361929bcc07d4fba0b161000e"
[[package]]
name = "windows-sys"
@ -5889,12 +5891,6 @@ dependencies = [
"windows_x86_64_msvc",
]
[[package]]
name = "windows-tokens"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b34c9a3b28cb41db7385546f7f9a8179348dffc89923dde66857b1ba5312f6b4"
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.48.0"

View File

@ -46,10 +46,6 @@
pub use LINGER as linger;
pub use TIMEVAL as timeval;
pub type CONDITION_VARIABLE = RTL_CONDITION_VARIABLE;
pub type SRWLOCK = RTL_SRWLOCK;
pub type INIT_ONCE = RTL_RUN_ONCE;
pub const CONDITION_VARIABLE_INIT: CONDITION_VARIABLE = CONDITION_VARIABLE { Ptr: ptr::null_mut() };
pub const SRWLOCK_INIT: SRWLOCK = SRWLOCK { Ptr: ptr::null_mut() };
pub const INIT_ONCE_STATIC_INIT: INIT_ONCE = INIT_ONCE { Ptr: ptr::null_mut() };
@ -224,7 +220,7 @@ pub struct in6_addr {
) -> BOOL {
windows_sys::ReadFileEx(
hFile.as_raw_handle(),
lpBuffer,
lpBuffer.cast::<u8>(),
nNumberOfBytesToRead,
lpOverlapped,
lpCompletionRoutine,

View File

@ -1,3 +1,6 @@
--out windows_sys.rs
--config flatten std
--filter
// tidy-alphabetical-start
Windows.Wdk.Storage.FileSystem.FILE_COMPLETE_IF_OPLOCKED
Windows.Wdk.Storage.FileSystem.FILE_CONTAINS_EXTENDED_CREATE_INFORMATION
@ -2108,7 +2111,6 @@ Windows.Win32.Networking.WinSock.WSABASEERR
Windows.Win32.Networking.WinSock.WSABUF
Windows.Win32.Networking.WinSock.WSACleanup
Windows.Win32.Networking.WinSock.WSADATA
Windows.Win32.Networking.WinSock.WSADATA
Windows.Win32.Networking.WinSock.WSADuplicateSocketW
Windows.Win32.Networking.WinSock.WSAEACCES
Windows.Win32.Networking.WinSock.WSAEADDRINUSE
@ -2420,8 +2422,6 @@ Windows.Win32.System.Console.STD_OUTPUT_HANDLE
Windows.Win32.System.Console.WriteConsoleW
Windows.Win32.System.Diagnostics.Debug.ARM64_NT_NEON128
Windows.Win32.System.Diagnostics.Debug.CONTEXT
Windows.Win32.System.Diagnostics.Debug.CONTEXT
Windows.Win32.System.Diagnostics.Debug.CONTEXT
Windows.Win32.System.Diagnostics.Debug.EXCEPTION_RECORD
Windows.Win32.System.Diagnostics.Debug.FACILITY_CODE
Windows.Win32.System.Diagnostics.Debug.FACILITY_NT_BIT
@ -2435,7 +2435,6 @@ Windows.Win32.System.Diagnostics.Debug.FORMAT_MESSAGE_OPTIONS
Windows.Win32.System.Diagnostics.Debug.FormatMessageW
Windows.Win32.System.Diagnostics.Debug.M128A
Windows.Win32.System.Diagnostics.Debug.XSAVE_FORMAT
Windows.Win32.System.Diagnostics.Debug.XSAVE_FORMAT
Windows.Win32.System.Environment.FreeEnvironmentStringsW
Windows.Win32.System.Environment.GetCommandLineW
Windows.Win32.System.Environment.GetCurrentDirectoryW
@ -2456,7 +2455,6 @@ Windows.Win32.System.Kernel.ExceptionContinueExecution
Windows.Win32.System.Kernel.ExceptionContinueSearch
Windows.Win32.System.Kernel.ExceptionNestedException
Windows.Win32.System.Kernel.FLOATING_SAVE_AREA
Windows.Win32.System.Kernel.FLOATING_SAVE_AREA
Windows.Win32.System.Kernel.OBJ_DONT_REPARSE
Windows.Win32.System.LibraryLoader.GetModuleFileNameW
Windows.Win32.System.LibraryLoader.GetModuleHandleA

View File

@ -32,11 +32,11 @@ pub fn BCryptGenRandom(
}
#[link(name = "kernel32")]
extern "system" {
pub fn AcquireSRWLockExclusive(srwlock: *mut RTL_SRWLOCK) -> ();
pub fn AcquireSRWLockExclusive(srwlock: *mut SRWLOCK) -> ();
}
#[link(name = "kernel32")]
extern "system" {
pub fn AcquireSRWLockShared(srwlock: *mut RTL_SRWLOCK) -> ();
pub fn AcquireSRWLockShared(srwlock: *mut SRWLOCK) -> ();
}
#[link(name = "kernel32")]
extern "system" {
@ -189,18 +189,15 @@ pub fn DuplicateHandle(
}
#[link(name = "kernel32")]
extern "system" {
pub fn FindClose(hfindfile: FindFileHandle) -> BOOL;
pub fn FindClose(hfindfile: HANDLE) -> BOOL;
}
#[link(name = "kernel32")]
extern "system" {
pub fn FindFirstFileW(
lpfilename: PCWSTR,
lpfindfiledata: *mut WIN32_FIND_DATAW,
) -> FindFileHandle;
pub fn FindFirstFileW(lpfilename: PCWSTR, lpfindfiledata: *mut WIN32_FIND_DATAW) -> HANDLE;
}
#[link(name = "kernel32")]
extern "system" {
pub fn FindNextFileW(hfindfile: FindFileHandle, lpfindfiledata: *mut WIN32_FIND_DATAW) -> BOOL;
pub fn FindNextFileW(hfindfile: HANDLE, lpfindfiledata: *mut WIN32_FIND_DATAW) -> BOOL;
}
#[link(name = "kernel32")]
extern "system" {
@ -360,7 +357,7 @@ pub fn GetOverlappedResult(
#[link(name = "kernel32")]
extern "system" {
pub fn InitOnceBeginInitialize(
lpinitonce: *mut RTL_RUN_ONCE,
lpinitonce: *mut INIT_ONCE,
dwflags: u32,
fpending: *mut BOOL,
lpcontext: *mut *mut ::core::ffi::c_void,
@ -369,7 +366,7 @@ pub fn InitOnceBeginInitialize(
#[link(name = "kernel32")]
extern "system" {
pub fn InitOnceComplete(
lpinitonce: *mut RTL_RUN_ONCE,
lpinitonce: *mut INIT_ONCE,
dwflags: u32,
lpcontext: *const ::core::ffi::c_void,
) -> BOOL;
@ -424,7 +421,7 @@ pub fn ReadConsoleW(
extern "system" {
pub fn ReadFile(
hfile: HANDLE,
lpbuffer: *mut ::core::ffi::c_void,
lpbuffer: *mut u8,
nnumberofbytestoread: u32,
lpnumberofbytesread: *mut u32,
lpoverlapped: *mut OVERLAPPED,
@ -434,7 +431,7 @@ pub fn ReadFile(
extern "system" {
pub fn ReadFileEx(
hfile: HANDLE,
lpbuffer: *mut ::core::ffi::c_void,
lpbuffer: *mut u8,
nnumberofbytestoread: u32,
lpoverlapped: *mut OVERLAPPED,
lpcompletionroutine: LPOVERLAPPED_COMPLETION_ROUTINE,
@ -442,11 +439,11 @@ pub fn ReadFileEx(
}
#[link(name = "kernel32")]
extern "system" {
pub fn ReleaseSRWLockExclusive(srwlock: *mut RTL_SRWLOCK) -> ();
pub fn ReleaseSRWLockExclusive(srwlock: *mut SRWLOCK) -> ();
}
#[link(name = "kernel32")]
extern "system" {
pub fn ReleaseSRWLockShared(srwlock: *mut RTL_SRWLOCK) -> ();
pub fn ReleaseSRWLockShared(srwlock: *mut SRWLOCK) -> ();
}
#[link(name = "kernel32")]
extern "system" {
@ -513,8 +510,8 @@ pub fn SetFileTime(
#[link(name = "kernel32")]
extern "system" {
pub fn SleepConditionVariableSRW(
conditionvariable: *mut RTL_CONDITION_VARIABLE,
srwlock: *mut RTL_SRWLOCK,
conditionvariable: *mut CONDITION_VARIABLE,
srwlock: *mut SRWLOCK,
dwmilliseconds: u32,
flags: u32,
) -> BOOL;
@ -549,11 +546,11 @@ pub fn SleepConditionVariableSRW(
}
#[link(name = "kernel32")]
extern "system" {
pub fn TryAcquireSRWLockExclusive(srwlock: *mut RTL_SRWLOCK) -> BOOLEAN;
pub fn TryAcquireSRWLockExclusive(srwlock: *mut SRWLOCK) -> BOOLEAN;
}
#[link(name = "kernel32")]
extern "system" {
pub fn TryAcquireSRWLockShared(srwlock: *mut RTL_SRWLOCK) -> BOOLEAN;
pub fn TryAcquireSRWLockShared(srwlock: *mut SRWLOCK) -> BOOLEAN;
}
#[link(name = "kernel32")]
extern "system" {
@ -574,19 +571,19 @@ pub fn WaitForMultipleObjects(
lphandles: *const HANDLE,
bwaitall: BOOL,
dwmilliseconds: u32,
) -> WIN32_ERROR;
) -> WAIT_EVENT;
}
#[link(name = "kernel32")]
extern "system" {
pub fn WaitForSingleObject(hhandle: HANDLE, dwmilliseconds: u32) -> WIN32_ERROR;
pub fn WaitForSingleObject(hhandle: HANDLE, dwmilliseconds: u32) -> WAIT_EVENT;
}
#[link(name = "kernel32")]
extern "system" {
pub fn WakeAllConditionVariable(conditionvariable: *mut RTL_CONDITION_VARIABLE) -> ();
pub fn WakeAllConditionVariable(conditionvariable: *mut CONDITION_VARIABLE) -> ();
}
#[link(name = "kernel32")]
extern "system" {
pub fn WakeConditionVariable(conditionvariable: *mut RTL_CONDITION_VARIABLE) -> ();
pub fn WakeConditionVariable(conditionvariable: *mut CONDITION_VARIABLE) -> ();
}
#[link(name = "kernel32")]
extern "system" {
@ -899,7 +896,17 @@ fn clone(&self) -> Self {
}
pub const CALLBACK_CHUNK_FINISHED: LPPROGRESS_ROUTINE_CALLBACK_REASON = 0u32;
pub const CALLBACK_STREAM_SWITCH: LPPROGRESS_ROUTINE_CALLBACK_REASON = 1u32;
pub type COMPARESTRING_RESULT = u32;
pub type COMPARESTRING_RESULT = i32;
#[repr(C)]
pub struct CONDITION_VARIABLE {
pub Ptr: *mut ::core::ffi::c_void,
}
impl ::core::marker::Copy for CONDITION_VARIABLE {}
impl ::core::clone::Clone for CONDITION_VARIABLE {
fn clone(&self) -> Self {
*self
}
}
pub type CONSOLE_MODE = u32;
#[repr(C)]
pub struct CONSOLE_READCONSOLE_CONTROL {
@ -917,7 +924,7 @@ fn clone(&self) -> Self {
#[repr(C)]
#[cfg(target_arch = "aarch64")]
pub struct CONTEXT {
pub ContextFlags: u32,
pub ContextFlags: CONTEXT_FLAGS,
pub Cpsr: u32,
pub Anonymous: CONTEXT_0,
pub Sp: u64,
@ -1004,7 +1011,7 @@ pub struct CONTEXT {
pub P4Home: u64,
pub P5Home: u64,
pub P6Home: u64,
pub ContextFlags: u32,
pub ContextFlags: CONTEXT_FLAGS,
pub MxCsr: u32,
pub SegCs: u16,
pub SegDs: u16,
@ -1100,7 +1107,7 @@ fn clone(&self) -> Self {
#[repr(C)]
#[cfg(target_arch = "x86")]
pub struct CONTEXT {
pub ContextFlags: u32,
pub ContextFlags: CONTEXT_FLAGS,
pub Dr0: u32,
pub Dr1: u32,
pub Dr2: u32,
@ -1134,6 +1141,7 @@ fn clone(&self) -> Self {
*self
}
}
pub type CONTEXT_FLAGS = u32;
pub const CP_UTF8: u32 = 65001u32;
pub const CREATE_ALWAYS: FILE_CREATION_DISPOSITION = 2u32;
pub const CREATE_BREAKAWAY_FROM_JOB: PROCESS_CREATION_FLAGS = 16777216u32;
@ -1151,9 +1159,9 @@ fn clone(&self) -> Self {
pub const CREATE_SHARED_WOW_VDM: PROCESS_CREATION_FLAGS = 4096u32;
pub const CREATE_SUSPENDED: PROCESS_CREATION_FLAGS = 4u32;
pub const CREATE_UNICODE_ENVIRONMENT: PROCESS_CREATION_FLAGS = 1024u32;
pub const CSTR_EQUAL: COMPARESTRING_RESULT = 2u32;
pub const CSTR_GREATER_THAN: COMPARESTRING_RESULT = 3u32;
pub const CSTR_LESS_THAN: COMPARESTRING_RESULT = 1u32;
pub const CSTR_EQUAL: COMPARESTRING_RESULT = 2i32;
pub const CSTR_GREATER_THAN: COMPARESTRING_RESULT = 3i32;
pub const CSTR_LESS_THAN: COMPARESTRING_RESULT = 1i32;
pub const DEBUG_ONLY_THIS_PROCESS: PROCESS_CREATION_FLAGS = 2u32;
pub const DEBUG_PROCESS: PROCESS_CREATION_FLAGS = 1u32;
pub const DELETE: FILE_ACCESS_RIGHTS = 65536u32;
@ -3369,7 +3377,6 @@ fn clone(&self) -> Self {
pub const FileStandardInfo: FILE_INFO_BY_HANDLE_CLASS = 1i32;
pub const FileStorageInfo: FILE_INFO_BY_HANDLE_CLASS = 16i32;
pub const FileStreamInfo: FILE_INFO_BY_HANDLE_CLASS = 7i32;
pub type FindFileHandle = *mut ::core::ffi::c_void;
pub type GENERIC_ACCESS_RIGHTS = u32;
pub const GENERIC_ALL: GENERIC_ACCESS_RIGHTS = 268435456u32;
pub const GENERIC_EXECUTE: GENERIC_ACCESS_RIGHTS = 536870912u32;
@ -3383,6 +3390,12 @@ pub struct GUID {
pub data3: u16,
pub data4: [u8; 8],
}
impl ::core::marker::Copy for GUID {}
impl ::core::clone::Clone for GUID {
fn clone(&self) -> Self {
*self
}
}
impl GUID {
pub const fn from_u128(uuid: u128) -> Self {
Self {
@ -3393,12 +3406,6 @@ pub const fn from_u128(uuid: u128) -> Self {
}
}
}
impl ::core::marker::Copy for GUID {}
impl ::core::clone::Clone for GUID {
fn clone(&self) -> Self {
*self
}
}
pub type HANDLE = *mut ::core::ffi::c_void;
pub type HANDLE_FLAGS = u32;
pub const HANDLE_FLAG_INHERIT: HANDLE_FLAGS = 1u32;
@ -3431,6 +3438,16 @@ fn clone(&self) -> Self {
pub const INFINITE: u32 = 4294967295u32;
pub const INHERIT_CALLER_PRIORITY: PROCESS_CREATION_FLAGS = 131072u32;
pub const INHERIT_PARENT_AFFINITY: PROCESS_CREATION_FLAGS = 65536u32;
#[repr(C)]
pub union INIT_ONCE {
pub Ptr: *mut ::core::ffi::c_void,
}
impl ::core::marker::Copy for INIT_ONCE {}
impl ::core::clone::Clone for INIT_ONCE {
fn clone(&self) -> Self {
*self
}
}
pub const INIT_ONCE_INIT_FAILED: u32 = 4u32;
pub const INVALID_FILE_ATTRIBUTES: u32 = 4294967295u32;
pub const INVALID_HANDLE_VALUE: HANDLE = ::core::ptr::invalid_mut(-1i32 as _);
@ -3659,10 +3676,10 @@ fn clone(&self) -> Self {
pub struct OBJECT_ATTRIBUTES {
pub Length: u32,
pub RootDirectory: HANDLE,
pub ObjectName: *mut UNICODE_STRING,
pub ObjectName: *const UNICODE_STRING,
pub Attributes: u32,
pub SecurityDescriptor: *mut ::core::ffi::c_void,
pub SecurityQualityOfService: *mut ::core::ffi::c_void,
pub SecurityDescriptor: *const ::core::ffi::c_void,
pub SecurityQualityOfService: *const ::core::ffi::c_void,
}
impl ::core::marker::Copy for OBJECT_ATTRIBUTES {}
impl ::core::clone::Clone for OBJECT_ATTRIBUTES {
@ -3712,8 +3729,8 @@ fn clone(&self) -> Self {
pub type PCWSTR = *const u16;
pub type PIO_APC_ROUTINE = ::core::option::Option<
unsafe extern "system" fn(
apccontext: *const ::core::ffi::c_void,
iostatusblock: *const IO_STATUS_BLOCK,
apccontext: *mut ::core::ffi::c_void,
iostatusblock: *mut IO_STATUS_BLOCK,
reserved: u32,
) -> (),
>;
@ -3755,36 +3772,6 @@ fn clone(&self) -> Self {
pub type PWSTR = *mut u16;
pub const READ_CONTROL: FILE_ACCESS_RIGHTS = 131072u32;
pub const REALTIME_PRIORITY_CLASS: PROCESS_CREATION_FLAGS = 256u32;
#[repr(C)]
pub struct RTL_CONDITION_VARIABLE {
pub Ptr: *mut ::core::ffi::c_void,
}
impl ::core::marker::Copy for RTL_CONDITION_VARIABLE {}
impl ::core::clone::Clone for RTL_CONDITION_VARIABLE {
fn clone(&self) -> Self {
*self
}
}
#[repr(C)]
pub union RTL_RUN_ONCE {
pub Ptr: *mut ::core::ffi::c_void,
}
impl ::core::marker::Copy for RTL_RUN_ONCE {}
impl ::core::clone::Clone for RTL_RUN_ONCE {
fn clone(&self) -> Self {
*self
}
}
#[repr(C)]
pub struct RTL_SRWLOCK {
pub Ptr: *mut ::core::ffi::c_void,
}
impl ::core::marker::Copy for RTL_SRWLOCK {}
impl ::core::clone::Clone for RTL_SRWLOCK {
fn clone(&self) -> Self {
*self
}
}
pub const SD_BOTH: WINSOCK_SHUTDOWN_HOW = 2i32;
pub const SD_RECEIVE: WINSOCK_SHUTDOWN_HOW = 0i32;
pub const SD_SEND: WINSOCK_SHUTDOWN_HOW = 1i32;
@ -3821,10 +3808,7 @@ fn clone(&self) -> Self {
*self
}
}
#[cfg(target_pointer_width = "32")]
pub type SOCKET = u32;
#[cfg(target_pointer_width = "64")]
pub type SOCKET = u64;
pub type SOCKET = usize;
pub const SOCKET_ERROR: i32 = -1i32;
pub const SOCK_DGRAM: WINSOCK_SOCKET_TYPE = 2i32;
pub const SOCK_RAW: WINSOCK_SOCKET_TYPE = 3i32;
@ -3838,6 +3822,16 @@ fn clone(&self) -> Self {
pub const SO_RCVTIMEO: i32 = 4102i32;
pub const SO_SNDTIMEO: i32 = 4101i32;
pub const SPECIFIC_RIGHTS_ALL: FILE_ACCESS_RIGHTS = 65535u32;
#[repr(C)]
pub struct SRWLOCK {
pub Ptr: *mut ::core::ffi::c_void,
}
impl ::core::marker::Copy for SRWLOCK {}
impl ::core::clone::Clone for SRWLOCK {
fn clone(&self) -> Self {
*self
}
}
pub const STACK_SIZE_PARAM_IS_A_RESERVATION: THREAD_CREATION_FLAGS = 65536u32;
pub const STANDARD_RIGHTS_ALL: FILE_ACCESS_RIGHTS = 2031616u32;
pub const STANDARD_RIGHTS_EXECUTE: FILE_ACCESS_RIGHTS = 131072u32;
@ -4008,12 +4002,13 @@ fn clone(&self) -> Self {
pub const VOLUME_NAME_DOS: GETFINALPATHNAMEBYHANDLE_FLAGS = 0u32;
pub const VOLUME_NAME_GUID: GETFINALPATHNAMEBYHANDLE_FLAGS = 1u32;
pub const VOLUME_NAME_NONE: GETFINALPATHNAMEBYHANDLE_FLAGS = 4u32;
pub const WAIT_ABANDONED: WIN32_ERROR = 128u32;
pub const WAIT_ABANDONED_0: WIN32_ERROR = 128u32;
pub const WAIT_FAILED: WIN32_ERROR = 4294967295u32;
pub const WAIT_IO_COMPLETION: WIN32_ERROR = 192u32;
pub const WAIT_OBJECT_0: WIN32_ERROR = 0u32;
pub const WAIT_TIMEOUT: WIN32_ERROR = 258u32;
pub const WAIT_ABANDONED: WAIT_EVENT = 128u32;
pub const WAIT_ABANDONED_0: WAIT_EVENT = 128u32;
pub type WAIT_EVENT = u32;
pub const WAIT_FAILED: WAIT_EVENT = 4294967295u32;
pub const WAIT_IO_COMPLETION: WAIT_EVENT = 192u32;
pub const WAIT_OBJECT_0: WAIT_EVENT = 0u32;
pub const WAIT_TIMEOUT: WAIT_EVENT = 258u32;
pub const WC_ERR_INVALID_CHARS: u32 = 128u32;
pub type WIN32_ERROR = u32;
#[repr(C)]

View File

@ -143,13 +143,8 @@ pub unsafe fn read_overlapped(
) -> io::Result<Option<usize>> {
let len = cmp::min(buf.len(), <c::DWORD>::MAX as usize) as c::DWORD;
let mut amt = 0;
let res = cvt(c::ReadFile(
self.as_raw_handle(),
buf.as_ptr() as c::LPVOID,
len,
&mut amt,
overlapped,
));
let res =
cvt(c::ReadFile(self.as_raw_handle(), buf.as_mut_ptr(), len, &mut amt, overlapped));
match res {
Ok(_) => Ok(Some(amt as usize)),
Err(e) => {

View File

@ -4,4 +4,4 @@ version = "0.1.0"
edition = "2021"
[dependencies.windows-bindgen]
version = "0.49"
version = "0.51.1"

View File

@ -1,5 +1,7 @@
use std::env;
use std::error::Error;
use std::fs;
use std::io::{self, Write};
use std::io::{self, Read, Seek, Write};
use std::path::PathBuf;
/// This is printed to the file before the rest of the contents.
@ -11,25 +13,20 @@
// ignore-tidy-filelength
"#;
fn main() -> io::Result<()> {
fn main() -> Result<(), Box<dyn Error>> {
let mut path: PathBuf =
std::env::args_os().nth(1).expect("a path to the rust repository is required").into();
path.push("library/std/src/sys/windows/c/windows_sys.lst");
env::args_os().nth(1).expect("a path to the rust repository is required").into();
path.push("library/std/src/sys/windows/c");
env::set_current_dir(&path)?;
// Load the list of APIs
let buffer = fs::read_to_string(&path)?;
let names: Vec<&str> = buffer
.lines()
.filter_map(|line| {
let line = line.trim();
if line.is_empty() || line.starts_with("//") { None } else { Some(line) }
})
.collect();
let info = windows_bindgen::bindgen(["--etc", "windows_sys.lst"])?;
println!("{info}");
// Write the bindings to windows-sys.rs
let bindings = windows_bindgen::standalone_std(&names);
path.set_extension("rs");
let mut f = std::fs::File::create(&path)?;
// add some gunk to the output file.
let mut f = fs::File::options().read(true).write(true).open("windows_sys.rs")?;
let mut bindings = String::new();
f.read_to_string(&mut bindings)?;
f.seek(io::SeekFrom::Start(0))?;
f.write_all(PRELUDE.as_bytes())?;
f.write_all(bindings.as_bytes())?;