mirror of
https://github.com/redstrate/Physis.git
synced 2025-04-20 11:47:46 +00:00
Implement write_string, add get_string_len helper function
This commit is contained in:
parent
119fefc8c9
commit
30ed0180ce
1 changed files with 8 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
// SPDX-FileCopyrightText: 2024 Joshua Goins <josh@redstrate.com>
|
// SPDX-FileCopyrightText: 2024 Joshua Goins <josh@redstrate.com>
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
use std::ffi::CString;
|
||||||
use binrw::{binread, BinReaderExt, BinResult};
|
use binrw::{binread, BinReaderExt, BinResult};
|
||||||
use half::f16;
|
use half::f16;
|
||||||
use std::io::SeekFrom;
|
use std::io::SeekFrom;
|
||||||
|
@ -22,7 +23,13 @@ pub(crate) fn read_string(byte_stream: Vec<u8>) -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn write_string(str: &String) -> Vec<u8> {
|
pub(crate) fn write_string(str: &String) -> Vec<u8> {
|
||||||
vec![]
|
let c_string = CString::new(&**str).unwrap();
|
||||||
|
c_string.as_bytes().to_vec()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn get_string_len(str: &String) -> usize {
|
||||||
|
let c_string = CString::new(&**str).unwrap();
|
||||||
|
c_string.count_bytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[binrw::parser(reader)]
|
#[binrw::parser(reader)]
|
||||||
|
|
Loading…
Add table
Reference in a new issue