Struct winsafe::HFILE [−][src]
#[repr(C)]pub struct HFILE { /* fields omitted */ }
Expand description
Handle to a
file.
Originally just a HANDLE
.
Implementations
Creates a new handle instance by wrapping a pointer.
This method is common to all handle types.
Consumes the handle returning the underlying raw pointer.
This method is common to all handle types.
Tells if the handle is invalid (null).
This method is common to all handle types.
CloseHandle
method.
pub fn CreateFile(
file_name: &str,
desired_access: GENERIC,
share_mode: FILE_SHARE,
security_attrs: Option<&mut SECURITY_ATTRIBUTES<'_>>,
creation_disposition: DISPOSITION,
flags_and_attrs: FILE_ATTRIBUTE,
hfile_template: Option<HFILE>
) -> WinResult<(HFILE, ERROR)>
pub fn CreateFile(
file_name: &str,
desired_access: GENERIC,
share_mode: FILE_SHARE,
security_attrs: Option<&mut SECURITY_ATTRIBUTES<'_>>,
creation_disposition: DISPOSITION,
flags_and_attrs: FILE_ATTRIBUTE,
hfile_template: Option<HFILE>
) -> WinResult<(HFILE, ERROR)>
CreateFile
static method.
Note: Must be paired with an
HFILE::CloseHandle
call.
Examples
Opening an existing file as read-only:
use winsafe::{co, HFILE};
let (hfile, status) = HFILE::CreateFile(
"C:\\Temp\\test.txt",
co::GENERIC::READ,
co::FILE_SHARE::READ,
None,
co::DISPOSITION::OPEN_EXISTING,
co::FILE_ATTRIBUTE::NORMAL,
None,
)?;
hfile.CloseHandle()?;
Opening a file for read and write. If the file doesn’t exist, create it:
use winsafe::{co, HFILE};
let (hfile, status) = HFILE::CreateFile(
"C:\\Temp\\test.txt",
co::GENERIC::READ | co::GENERIC::WRITE,
co::FILE_SHARE::NONE,
None,
co::DISPOSITION::OPEN_ALWAYS,
co::FILE_ATTRIBUTE::NORMAL,
None,
)?;
hfile.CloseHandle()?;
CreateFileMapping
method.
Note: Must be paired with an
HFILEMAP::CloseHandle
call.
GetFileInformationByHandle
method.
GetFileSizeEx
method.
GetFileType
method.
LockFile
method.
Note: Must be paired with an
HFILE::UnlockFile
call.
ReadFile
method.
SetEndOfFile
method.
pub fn SetFilePointerEx(
self,
distance_to_move: i64,
move_method: FILE_STARTING_POINT
) -> WinResult<i64>
pub fn SetFilePointerEx(
self,
distance_to_move: i64,
move_method: FILE_STARTING_POINT
) -> WinResult<i64>
SetFilePointerEx
method.
UnlockFile
method.
Trait Implementations
Auto Trait Implementations
Blanket Implementations
Mutably borrows from an owned value. Read more