-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
the github ignore whitespace feature is quite handy for commits like this
- Loading branch information
Showing
17 changed files
with
1,072 additions
and
858 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,31 @@ | ||
|
||
use std::fs; | ||
use std::io; | ||
use std::path::PathBuf; | ||
|
||
/// Return all files in directory and subdirectories | ||
pub fn read_dir_recursive(src: &PathBuf) -> Result<Vec<PathBuf>, io::Error> { | ||
let mut res = Vec::new(); | ||
for item in fs::read_dir(src)? { | ||
let path = item?.path(); | ||
if path.is_dir() { | ||
res.extend(read_dir_recursive(src)?); | ||
} | ||
else { | ||
res.push(path); | ||
} | ||
} | ||
Ok(res) | ||
} | ||
|
||
pub fn copy_dir_recursive(src: &PathBuf, dest: &PathBuf) -> Result<(), io::Error> { | ||
fs::create_dir_all(dest)?; | ||
for item in fs::read_dir(src)? { | ||
let item_path = item?.path(); | ||
let dest_path = dest.join(item_path.file_name().unwrap()); | ||
if item_path.is_dir() { | ||
copy_dir_recursive(&item_path, &dest_path)?; | ||
} | ||
else { | ||
fs::copy(&item_path, &dest_path)?; | ||
} | ||
} | ||
Ok(()) | ||
} | ||
use std::fs; | ||
use std::io; | ||
use std::path::PathBuf; | ||
|
||
/// Return all files in directory and subdirectories | ||
pub fn read_dir_recursive(src: &PathBuf) -> Result<Vec<PathBuf>, io::Error> { | ||
let mut res = Vec::new(); | ||
for item in fs::read_dir(src)? { | ||
let path = item?.path(); | ||
if path.is_dir() { | ||
res.extend(read_dir_recursive(src)?); | ||
} else { | ||
res.push(path); | ||
} | ||
} | ||
Ok(res) | ||
} | ||
|
||
pub fn copy_dir_recursive(src: &PathBuf, dest: &PathBuf) -> Result<(), io::Error> { | ||
fs::create_dir_all(dest)?; | ||
for item in fs::read_dir(src)? { | ||
let item_path = item?.path(); | ||
let dest_path = dest.join(item_path.file_name().unwrap()); | ||
if item_path.is_dir() { | ||
copy_dir_recursive(&item_path, &dest_path)?; | ||
} else { | ||
fs::copy(&item_path, &dest_path)?; | ||
} | ||
} | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.