resetprop: replace nanopb with quick-protobuf for persist

This commit is contained in:
LoveSy
2023-06-23 20:37:06 +08:00
committed by John Wu
parent 7826d7527f
commit 8d81bd0e33
17 changed files with 330 additions and 305 deletions
+21
View File
@@ -345,6 +345,27 @@ impl Directory {
})?;
Ok(())
}
pub fn for_all_file<F: FnMut(&DirEntry) -> io::Result<WalkResult>>(
&mut self,
mut f: F,
) -> io::Result<WalkResult> {
use WalkResult::*;
loop {
match self.read()? {
None => return Ok(Continue),
Some(ref e) => {
if e.is_dir() {
return Ok(Continue);
}
match f(e)? {
Abort | Skip => return Ok(Continue),
Continue => {}
}
}
}
}
}
}
impl Directory {
+3 -3
View File
@@ -83,14 +83,14 @@ macro_rules! bfmt_cstr {
#[macro_export]
macro_rules! cstr {
($str:literal) => {{
($($str:tt)*) => {{
assert!(
!$str.bytes().any(|b| b == b'\0'),
!($($str)*).bytes().any(|b| b == b'\0'),
"cstr argument contains embedded NUL bytes",
);
#[allow(unused_unsafe)]
unsafe {
$crate::Utf8CStr::from_bytes_unchecked(concat!($str, "\0").as_bytes())
$crate::Utf8CStr::from_bytes_unchecked(concat!($($str)*, "\0").as_bytes())
}
}};
}