Skip to content

Commit

Permalink
create a to gtok file
Browse files Browse the repository at this point in the history
  • Loading branch information
nleroy917 committed Jan 22, 2024
1 parent 81afa96 commit 114fe48
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions genimtools/src/common/models/tokenized_regionset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,21 @@ impl<'a> TokenizedRegionSet<'a> {
Ok(())
}

///
/// Write a TokenizedRegionSet to a .gtok file
/// * `path` - A PathBuf to write the .gtok file to
///
pub fn to_gtok_file(&self, path: &PathBuf) -> Result<(), Box<dyn Error>> {
let mut file = File::create(path)?;
for region in self.regions.iter() {
let id = self.universe.convert_region_to_id(region);
let line = format!("{}\n", id);
file.write_all(line.as_bytes())?;
}

Ok(())
}

///
/// Convert a TokenizedRegionSet to a vector of region IDs
///
Expand Down

0 comments on commit 114fe48

Please sign in to comment.