Still not working.

This commit is contained in:
Elf M. Sternberg 2022-11-26 17:59:57 -08:00
parent 550d4c1876
commit a01fcbee68
1 changed files with 18 additions and 4 deletions

View File

@ -31,14 +31,14 @@ pub impl Squozen {
} }
/* /*
pub fn iter(&mut self) -> StoredPath { pub fn matches(&mut self, pattern: &[u8]) -> StoredPath {
FoundPath::new(&self); FoundPath::new(&self, pattern);
} }
*/ */
} }
pub struct StoredPath<'a> { pub struct StoredPath<'a> {
source: Squozen, source: &'a Squozen,
path: [char; libc::PATH_MAX], path: [char; libc::PATH_MAX],
db: Bytes<Bufreader>, db: Bytes<Bufreader>,
ch: u8, ch: u8,
@ -47,7 +47,7 @@ pub struct StoredPath<'a> {
} }
pub impl<'a> StoredPath { pub impl<'a> StoredPath {
pub fn new(squozen: Squozen) -> StoredPath { pub fn new(squozen: &'a mut Squozen) -> StoredPath {
let mut dbfile = File::open(&squozen.path)?; let mut dbfile = File::open(&squozen.path)?;
let mut dbbuffer = Bufreader::new(dbfile); let mut dbbuffer = Bufreader::new(dbfile);
dbbuffer.seek(BIGRAMS); dbbuffer.seek(BIGRAMS);
@ -104,3 +104,17 @@ pub impl<'a> Iterator for StoredPath {
Some(&self.path) Some(&self.path)
} }
} }
pub struct FoundPath {
stored: StoredPath,
pattern: Vec<u8>,
}
pub impl<'a> FoundPath {
pub fn new(squozen: &'a Squozen, path: &[u8]) -> Result<FoundPath, Error> {
Ok(FoundPath {
stored: StoredPath::new(squozen),
pattern: prepare_pattern(path)?,
})
}
}