| 1370 | } |
| 1371 | |
| 1372 | fn c_string_array(strings: &[&str]) -> Result<(Vec<CString>, Vec<*const libc::c_char>), String> { |
| 1373 | let owned: Vec<CString> = strings |
| 1374 | .iter() |
| 1375 | .map(|s| CString::new(*s)) |
| 1376 | .collect::<Result<Vec<_>, _>>() |
| 1377 | .map_err(|e| format!("invalid string array entry: {e}"))?; |
| 1378 | let mut ptrs: Vec<*const libc::c_char> = owned.iter().map(|c| c.as_ptr()).collect(); |
| 1379 | ptrs.push(ptr::null()); |
| 1380 | Ok((owned, ptrs)) |
| 1381 | } |
| 1382 | |
| 1383 | fn path_to_cstring(path: &Path) -> Result<CString, String> { |
| 1384 | let path = path |