-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dac8f42
commit 116fa2b
Showing
4 changed files
with
29 additions
and
18 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
pub mod body; | ||
pub mod gql_type; | ||
pub mod headers; | ||
pub mod path; | ||
pub mod url; | ||
pub mod value; |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use std::fs; | ||
use std::path::Path; | ||
|
||
use pathdiff::diff_paths; | ||
|
||
/// Checks if file or folder already exists or not. | ||
pub fn is_exists(path: &str) -> bool { | ||
fs::metadata(path).is_ok() | ||
} | ||
|
||
/// Expects both paths to be absolute and returns a relative path from `from` to | ||
/// `to`. expects `from`` to be directory. | ||
pub fn to_relative_path(from: &Path, to: &str) -> Option<String> { | ||
let from_path = Path::new(from).to_path_buf(); | ||
let to_path = Path::new(to).to_path_buf(); | ||
|
||
// Calculate the relative path from `from_path` to `to_path` | ||
diff_paths(to_path, from_path).map(|p| p.to_string_lossy().to_string()) | ||
} |