mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 04:02:00 -06:00
Leave special files untouched from renaming
This commit is contained in:
parent
022f23e3ab
commit
2c3bd78fc1
1 changed files with 6 additions and 0 deletions
|
|
@ -37,6 +37,12 @@ pub fn tempfile<S: AsRef<str>>(suffix: S) -> io::Result<NamedTempFile> {
|
|||
|
||||
/// Check if the given path exists and rename it until the new (renamed) file does not exist.
|
||||
pub fn free_file(mut path: PathBuf) -> PathBuf {
|
||||
// if path is not a file and not a dir it's probably a pipe on linux which reguarly is intended
|
||||
// and thus does not need to be renamed. what it is on windows ¯\_(ツ)_/¯
|
||||
if !path.is_file() && !path.is_dir() {
|
||||
return path;
|
||||
}
|
||||
|
||||
let mut i = 0;
|
||||
while path.exists() {
|
||||
i += 1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue