mirror of
https://github.com/patarapolw/cjdic2.git
synced 2026-11-09 17:39:35 +00:00
add yomitan import db/scripts
This commit is contained in:
1 parent
c4103dda7d
commit
8330a78c12
10 files changed
+535
-2
No files matched your search
@@ -0,0 +1,29 @@
|
||||
use std::{
|
||||
fs::read_dir,
|
||||
path::{Path, absolute},
|
||||
};
|
||||
|
||||
use anyhow::{Context, Ok};
|
||||
use cjdic2_core::db::import_bundled_zip_file;
|
||||
use rusqlite::Connection;
|
||||
|
||||
fn main() -> Result<(), anyhow::Error> {
|
||||
let conn = &mut Connection::open("test.db")?;
|
||||
let zip_dir = Path::new("src-tauri/resources/yomitan");
|
||||
println!("zip_dir: {:?}", absolute(zip_dir)); // Relative to workspace root
|
||||
|
||||
for entry in
|
||||
read_dir(&zip_dir).with_context(|| format!("reading zip dir {}", zip_dir.display()))?
|
||||
{
|
||||
let e = entry?;
|
||||
let p = e.path();
|
||||
|
||||
if p.extension().and_then(|s| s.to_str()) == Some("zip") {
|
||||
println!("zip_file: {:?}", p);
|
||||
println!("{:?}", import_bundled_zip_file(conn, p)?);
|
||||
} else {
|
||||
println!("not zip_file: {:?}", p);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
Reference in new issue
Block a user