(volume: OsPath, vm: &VirtualMachine)
| 1882 | |
| 1883 | #[pyfunction] |
| 1884 | fn listmounts(volume: OsPath, vm: &VirtualMachine) -> PyResult<PyListRef> { |
| 1885 | use windows_sys::Win32::Foundation::ERROR_MORE_DATA; |
| 1886 | |
| 1887 | let wide = volume.to_wide_cstring(vm)?; |
| 1888 | let mut buflen: u32 = Foundation::MAX_PATH + 1; |
| 1889 | let mut buffer: Vec<u16> = vec![0; buflen as usize]; |
| 1890 | |
| 1891 | loop { |
| 1892 | let success = unsafe { |
| 1893 | FileSystem::GetVolumePathNamesForVolumeNameW( |
| 1894 | wide.as_ptr(), |
| 1895 | buffer.as_mut_ptr(), |
| 1896 | buflen, |
| 1897 | &mut buflen, |
| 1898 | ) |
| 1899 | }; |
| 1900 | if success != 0 { |
| 1901 | break; |
| 1902 | } |
| 1903 | let err = io::Error::last_os_error(); |
| 1904 | if err.raw_os_error() == Some(ERROR_MORE_DATA as i32) { |
| 1905 | buffer.resize(buflen as usize, 0); |
| 1906 | continue; |
| 1907 | } |
| 1908 | return Err(err.to_pyexception(vm)); |
| 1909 | } |
| 1910 | |
| 1911 | // Parse null-separated strings |
| 1912 | let mut result = Vec::new(); |
| 1913 | let mut start = 0; |
| 1914 | for (i, &c) in buffer.iter().enumerate() { |
| 1915 | if c == 0 { |
| 1916 | if i > start { |
| 1917 | let mount = String::from_utf16_lossy(&buffer[start..i]); |
| 1918 | result.push(vm.new_pyobj(mount)); |
| 1919 | } |
| 1920 | start = i + 1; |
| 1921 | if start < buffer.len() && buffer[start] == 0 { |
| 1922 | break; // Double null = end |
| 1923 | } |
| 1924 | } |
| 1925 | } |
| 1926 | |
| 1927 | Ok(vm.ctx.new_list(result)) |
| 1928 | } |
| 1929 | |
| 1930 | #[pyfunction] |
| 1931 | fn set_handle_inheritable( |
nothing calls this directly
no test coverage detected