-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Add support for Dates to CLDRJsonDataProvider * Apply feedback
- Loading branch information
1 parent
ab00f54
commit 97e53be
Showing
5 changed files
with
1,065 additions
and
4 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 |
---|---|---|
@@ -1,11 +1,24 @@ | ||
use crate::error::Error; | ||
use std::fs; | ||
use std::fs::File; | ||
use std::io::BufReader; | ||
use std::path::PathBuf; | ||
use std::path::{Path, PathBuf}; | ||
|
||
/// Helper function to open a file and return failures as a crate error. | ||
pub fn open_reader(path: PathBuf) -> Result<BufReader<File>, Error> { | ||
File::open(&path) | ||
.map(BufReader::new) | ||
.map_err(|e| Error::IoError(e, path)) | ||
} | ||
|
||
/// Helper function which returns a sorted list of subdirectories. | ||
pub fn get_subdirectories(root: &Path) -> Result<Vec<PathBuf>, Error> { | ||
let mut result = vec![]; | ||
for entry in fs::read_dir(root).map_err(|e| Error::IoError(e, root.to_path_buf()))? { | ||
let entry = entry.map_err(|e| Error::IoError(e, root.to_path_buf()))?; | ||
let path = entry.path(); | ||
result.push(path); | ||
} | ||
result.sort(); | ||
Ok(result) | ||
} |
Oops, something went wrong.