From 3cbe1f51db5669c5561d1d0f4ff02a64e7cd6728 Mon Sep 17 00:00:00 2001 From: Matt Bilker Date: Thu, 6 Sep 2018 18:08:53 +0000 Subject: [PATCH] lib: support writing attribute key names uncompressed --- src/lib.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 7c22a02..f592c91 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -196,7 +196,6 @@ impl KbinXml { count); node_buf.write_u8(node_type.id | array_mask).context(KbinErrorKind::DataWrite(node_type.name))?; - match self.options.compression { Compression::Compressed => Sixbit::pack(&mut **node_buf, input.name())?, Compression::Uncompressed => { @@ -252,7 +251,15 @@ impl KbinXml { let node_type = StandardType::Attribute; node_buf.write_u8(node_type.id).context(KbinErrorKind::DataWrite(node_type.name))?; - Sixbit::pack(&mut **node_buf, key)?; + match self.options.compression { + Compression::Compressed => Sixbit::pack(&mut **node_buf, key)?, + Compression::Uncompressed => { + let data = self.options.encoding.encode_bytes(key)?; + let len = (data.len() - 1) as u8; + node_buf.write_u8(len | ARRAY_MASK).context(KbinErrorKind::DataWrite("attribute name length"))?; + node_buf.write_all(&data).context(KbinErrorKind::DataWrite("node name bytes"))?; + }, + }; } for child in input.children() {