-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Dates to CLDRJsonDataProvider
- Loading branch information
1 parent
6d85f62
commit 9265129
Showing
4 changed files
with
397 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,22 @@ | ||
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)) | ||
} | ||
|
||
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); | ||
} | ||
Ok(result) | ||
} |
Oops, something went wrong.