changes...
This commit is contained in:
parent
6af6e65666
commit
40ca10651f
18 changed files with 998 additions and 112 deletions
18
src/rmc/structures/string.rs
Normal file
18
src/rmc/structures/string.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
use std::ffi::CString;
|
||||
use std::io::{Read, Seek};
|
||||
use log::error;
|
||||
use crate::endianness::{IS_BIG_ENDIAN, ReadExtensions};
|
||||
use super::Result;
|
||||
|
||||
pub fn read(reader: &mut (impl Read + Seek)) -> Result<String>{
|
||||
let len: u16 = reader.read_struct(IS_BIG_ENDIAN)?;
|
||||
let mut data = vec![0; len as usize - 1];
|
||||
reader.read_exact(&mut data)?;
|
||||
|
||||
let null: u8 = reader.read_struct(IS_BIG_ENDIAN)?;
|
||||
if null != 0{
|
||||
error!("unable to find null terminator... continuing anyways");
|
||||
}
|
||||
|
||||
Ok(String::from_utf8(data)?)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue