Returns the path to a temporary directory in which to store files backing the shared memory. If it doesn't exist, the directory is created.
()
| 116 | /// Returns the path to a temporary directory in which to store files backing the shared memory. If it |
| 117 | /// doesn't exist, the directory is created. |
| 118 | fn get_tmp_dir() -> Result<PathBuf, ShmemError> { |
| 119 | debug!("Getting & creating shared_memory-rs temp dir"); |
| 120 | let mut path = std::env::temp_dir(); |
| 121 | path.push("shared_memory-rs"); |
| 122 | |
| 123 | if path.is_dir() { |
| 124 | return Ok(path); |
| 125 | } |
| 126 | |
| 127 | match std::fs::create_dir_all(path.as_path()) { |
| 128 | Ok(_) => Ok(path), |
| 129 | Err(e) if e.kind() == ErrorKind::AlreadyExists => Ok(path), |
| 130 | Err(e) => Err(ShmemError::UnknownOsError(e.raw_os_error().unwrap() as _)), |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | fn new_map( |
| 135 | unique_id: &str, |