/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use std::ffi::CStr; use std::fs::File; use std::io::{Read, Result as IOResult, Seek, SeekFrom}; use std::path::Path;
use nserror::{nsresult, NS_ERROR_INVALID_ARG, NS_ERROR_NOT_AVAILABLE, NS_ERROR_OUT_OF_MEMORY};
impl BuildIdReader { pubfn new(filename: &Path) -> Result<Self, nsresult> {
trace!("BuildIdReader::new {:?}", filename); let f = File::open(filename).map_err(|e| {
error!( "BuildIdReader::new failed to open {:?} with error {}",
filename, e
);
NS_ERROR_INVALID_ARG
})?;
Ok(BuildIdReader { file: f })
}
fn read_raw_build_id(&mutself, note_name: &str) -> Result<Vec<u8>, nsresult> {
trace!("BuildIdReader::read_raw_build_id {}", note_name); letmut buffer = [0; MAX_BUFFER_READ]; let _ = self.file.read_exact(&mut buffer).map_err(|e| {
error!("BuildIdReader::read_raw_build_id failed to read exact buffer of size {} with error {}", MAX_BUFFER_READ, e);
NS_ERROR_OUT_OF_MEMORY
})?;
// This does actually depend on the platform, so it's not in this // impl nor source file but in the platform-dependant modules listed at // the end of this file self.get_build_id_bytes(&buffer, note_name)
}
pubfn read_string_build_id(&mutself, note_name: &str) -> Result<String, nsresult> {
trace!("BuildIdReader::read_string_build_id {}", note_name); let b = self.read_raw_build_id(note_name).map_err(|err| {
error!( "BuildIdReader::read_string_build_id failed to read raw build id with error {}",
err
);
err
})?; Self::string_from_bytes(&b).ok_or(NS_ERROR_NOT_AVAILABLE)
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.