1
Fork 0
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:
Joshua Goins 2024-06-29 12:36:54 -04:00
parent 119fefc8c9
commit 30ed0180ce

View file

@ -1,6 +1,7 @@
// SPDX-FileCopyrightText: 2024 Joshua Goins <josh@redstrate.com>
// SPDX-License-Identifier: GPL-3.0-or-later
use std::ffi::CString;
use binrw::{binread, BinReaderExt, BinResult};
use half::f16;
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> {
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)]