MCPcopy Index your code
hub / github.com/RustPython/RustPython / CreateFile

Function CreateFile

crates/vm/src/stdlib/_winapi.rs:101–132  ·  view source on GitHub ↗
(
        file_name: PyStrRef,
        desired_access: u32,
        share_mode: u32,
        _security_attributes: PyObjectRef, // Always NULL (0)
        creation_disposition: u32,
        flags_and_

Source from the content-addressed store, hash-verified

99 reason = "matches Win32 CreateFile parameter structure"
100 )]
101 fn CreateFile(
102 file_name: PyStrRef,
103 desired_access: u32,
104 share_mode: u32,
105 _security_attributes: PyObjectRef, // Always NULL (0)
106 creation_disposition: u32,
107 flags_and_attributes: u32,
108 _template_file: PyObjectRef, // Always NULL (0)
109 vm: &VirtualMachine,
110 ) -> PyResult<WinHandle> {
111 use windows_sys::Win32::Storage::FileSystem::CreateFileW;
112
113 let file_name_wide = file_name.as_wtf8().to_wide_with_nul();
114
115 let handle = unsafe {
116 CreateFileW(
117 file_name_wide.as_ptr(),
118 desired_access,
119 share_mode,
120 null(),
121 creation_disposition,
122 flags_and_attributes,
123 null_mut(),
124 )
125 };
126
127 if handle == windows_sys::Win32::Foundation::INVALID_HANDLE_VALUE {
128 return Err(vm.new_last_os_error());
129 }
130
131 Ok(WinHandle(handle))
132 }
133
134 #[pyfunction]
135 fn GetStdHandle(

Callers

nothing calls this directly

Calls 6

WinHandleClass · 0.85
to_wide_with_nulMethod · 0.80
new_last_os_errorMethod · 0.80
ErrClass · 0.50
as_wtf8Method · 0.45
as_ptrMethod · 0.45

Tested by

no test coverage detected