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

Method create_mmap_windows

crates/stdlib/src/mmap.rs:1433–1460  ·  view source on GitHub ↗
(
            handle: HANDLE,
            offset: i64,
            size: usize,
            access: &AccessMode,
        )

Source from the content-addressed store, hash-verified

1431 impl PyMmap {
1432 #[cfg(windows)]
1433 fn create_mmap_windows(
1434 handle: HANDLE,
1435 offset: i64,
1436 size: usize,
1437 access: &AccessMode,
1438 ) -> io::Result<MmapObj> {
1439 use std::fs::File;
1440
1441 // Create an owned handle wrapper for memmap2
1442 // We need to create a File from the handle
1443 let file = unsafe { File::from_raw_handle(handle as RawHandle) };
1444
1445 let mut mmap_opt = MmapOptions::new();
1446 let mmap_opt = mmap_opt.offset(offset as u64).len(size);
1447
1448 let result = match access {
1449 AccessMode::Default | AccessMode::Write => {
1450 unsafe { mmap_opt.map_mut(&file) }.map(MmapObj::Write)
1451 }
1452 AccessMode::Read => unsafe { mmap_opt.map(&file) }.map(MmapObj::Read),
1453 AccessMode::Copy => unsafe { mmap_opt.map_copy(&file) }.map(MmapObj::Write),
1454 };
1455
1456 // Don't close the file handle - we're borrowing it
1457 core::mem::forget(file);
1458
1459 result
1460 }
1461
1462 /// Try to restore mmap after a failed resize operation.
1463 /// Returns true if restoration succeeded, false otherwise.

Callers

nothing calls this directly

Calls 5

newFunction · 0.85
forgetFunction · 0.85
lenMethod · 0.45
offsetMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected