Function rs_utils::file::file_path_incremental
[−]
[src]
pub fn file_path_incremental(file_path: &Path) -> Result<PathBuf, Error>
Returns the file path appended with suffix -N
where N
gives
the first available non-pre-existing filename starting from 0
.
This function only queries for the next available filename, no directories or files are created.
Examples
let file_path = Path::new ("somedir/somefile"); assert_eq!( file_path_incremental (file_path).unwrap().to_str().unwrap(), "somedir/somefile-0" );
Errors
- Invalid unicode (☞ see
is_file
) - Not a file:
let e = file_path_incremental (Path::new ("somepath/")).err().unwrap(); assert_eq!(e.kind(), ErrorKind::InvalidInput); assert_eq!(e.description(), "not a file");