1 // These were copied from libstd/sys/windows/c.rs out of necessity; and even five years after I
2 // first wrote this crate, I’m amused to note winapi 0.3.9 still lacks REPARSE_DATA_BUFFER, though
3 // it’s picked up MAXIMUM_REPARSE_DATA_BUFFER_SIZE since 0.2.8, the other thing that was missing.
4 // Anyway, I just threw in the towel and decided not to use kernel32-sys and winapi at all.
6 #![allow(non_snake_case, non_camel_case_types)]
8 use std
::os
::raw
::{c_int
, c_uint
, c_ushort
, c_ulong
, c_void
};
9 use std
::os
::windows
::raw
::HANDLE
;
12 pub type DWORD
= c_ulong
;
13 pub type BOOL
= c_int
;
14 pub type LPVOID
= *mut c_void
;
15 pub type LPDWORD
= *mut DWORD
;
16 pub type LPCWSTR
= *const WCHAR
;
17 pub type LPOVERLAPPED
= *mut OVERLAPPED
;
18 pub type LPBY_HANDLE_FILE_INFORMATION
= *mut BY_HANDLE_FILE_INFORMATION
;
19 pub type LPSECURITY_ATTRIBUTES
= *mut SECURITY_ATTRIBUTES
;
21 pub const FILE_ATTRIBUTE_DIRECTORY
: DWORD
= 0x10;
22 pub const FILE_ATTRIBUTE_REPARSE_POINT
: DWORD
= 0x400;
24 pub const IO_REPARSE_TAG_SYMLINK
: DWORD
= 0xa000000c;
25 pub const IO_REPARSE_TAG_MOUNT_POINT
: DWORD
= 0xa0000003;
27 pub const FILE_SHARE_DELETE
: DWORD
= 0x4;
28 pub const FILE_SHARE_READ
: DWORD
= 0x1;
29 pub const FILE_SHARE_WRITE
: DWORD
= 0x2;
31 pub const OPEN_EXISTING
: DWORD
= 3;
32 pub const FILE_FLAG_BACKUP_SEMANTICS
: DWORD
= 0x02000000;
34 pub const INVALID_HANDLE_VALUE
: HANDLE
= !0 as HANDLE
;
36 pub const MAXIMUM_REPARSE_DATA_BUFFER_SIZE
: usize = 16 * 1024;
37 pub const FSCTL_GET_REPARSE_POINT
: DWORD
= 0x900a8;
40 pub struct BY_HANDLE_FILE_INFORMATION
{
41 pub dwFileAttributes
: DWORD
,
42 pub ftCreationTime
: FILETIME
,
43 pub ftLastAccessTime
: FILETIME
,
44 pub ftLastWriteTime
: FILETIME
,
45 pub dwVolumeSerialNumber
: DWORD
,
46 pub nFileSizeHigh
: DWORD
,
47 pub nFileSizeLow
: DWORD
,
48 pub nNumberOfLinks
: DWORD
,
49 pub nFileIndexHigh
: DWORD
,
50 pub nFileIndexLow
: DWORD
,
54 pub struct REPARSE_DATA_BUFFER
{
55 pub ReparseTag
: c_uint
,
56 pub ReparseDataLength
: c_ushort
,
57 pub Reserved
: c_ushort
,
62 #[derive(Copy, Clone)]
64 pub dwLowDateTime
: DWORD
,
65 pub dwHighDateTime
: DWORD
,
69 pub struct OVERLAPPED
{
70 pub Internal
: *mut c_ulong
,
71 pub InternalHigh
: *mut c_ulong
,
73 pub OffsetHigh
: DWORD
,
78 pub struct SECURITY_ATTRIBUTES
{
80 pub lpSecurityDescriptor
: LPVOID
,
81 pub bInheritHandle
: BOOL
,
85 pub fn CreateFileW(lpFileName
: LPCWSTR
,
86 dwDesiredAccess
: DWORD
,
88 lpSecurityAttributes
: LPSECURITY_ATTRIBUTES
,
89 dwCreationDisposition
: DWORD
,
90 dwFlagsAndAttributes
: DWORD
,
91 hTemplateFile
: HANDLE
)
93 pub fn GetFileInformationByHandle(hFile
: HANDLE
,
94 lpFileInformation
: LPBY_HANDLE_FILE_INFORMATION
)
96 pub fn DeviceIoControl(hDevice
: HANDLE
,
97 dwIoControlCode
: DWORD
,
101 nOutBufferSize
: DWORD
,
102 lpBytesReturned
: LPDWORD
,
103 lpOverlapped
: LPOVERLAPPED
) -> BOOL
;
104 pub fn CloseHandle(hObject
: HANDLE
) -> BOOL
;