-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Export
get_scheme_files
to allow users to get &[SchemeFile] from dir
- Loading branch information
1 parent
821b1a8
commit 7d3a617
Showing
11 changed files
with
597 additions
and
421 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use anyhow::{Context, Result}; | ||
use std::fs::{remove_file, File}; | ||
use std::io::Write; | ||
use std::path::Path; | ||
|
||
#[allow(dead_code)] | ||
pub(crate) fn write_to_file(path: impl AsRef<Path>, contents: &str) -> Result<()> { | ||
if path.as_ref().exists() { | ||
remove_file(path.as_ref()) | ||
.with_context(|| format!("Unable to remove file: {}", path.as_ref().display()))?; | ||
} | ||
|
||
let mut file = File::create(path.as_ref()) | ||
.with_context(|| format!("Unable to create file: {}", path.as_ref().display()))?; | ||
|
||
file.write_all(contents.as_bytes())?; | ||
|
||
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
Oops, something went wrong.