(path: &Path)
| 201 | } |
| 202 | |
| 203 | pub(crate) fn next_backup_path(path: &Path) -> PathBuf { |
| 204 | let first = PathBuf::from(format!("{}.bak", path.display())); |
| 205 | if !first.exists() { |
| 206 | return first; |
| 207 | } |
| 208 | |
| 209 | let mut idx = 1; |
| 210 | loop { |
| 211 | let candidate = PathBuf::from(format!("{}.bak.{}", path.display(), idx)); |
| 212 | if !candidate.exists() { |
| 213 | return candidate; |
| 214 | } |
| 215 | idx += 1; |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | #[cfg(test)] |
| 220 | mod tests { |
no outgoing calls