A binary file read/write library written in swift. It was created with the purpose of being able to somewhat easily read game data files.
NOTE: writeString prefixes the length of the given string as a generic Int. This could cause compatibility issues on 32/64-bit systems
Write: LittleEndian
var writeTest: BinaryWriter = BinaryWriter()
try writeTest.writeVariableLengthString("This is a test!", .ascii)
try writeTest.writeNullTerminatedString("This is my second test!", .ascii)
try writeTest.writeUInt64(866464616516564)
Write: BigEndian
var writeTest: BinaryWriter = BinaryWriter()
try writeTest.writeUInt64(866464616516564, bigEndian: true)
Read: LittleEndian
var reader: BinaryReader = BinaryReader(writeTest.data)
print("\(try reader.readVariableLengthString(.ascii))")
print("\(try reader.readNullTerminatedString(.ascii))")
print("\(try reader.readUInt64())")
Read: BigEndian
var reader: BinaryReader = BinaryReader(writeTest.data)
print("\(try reader.readUInt64(true))")
SwiftyBytes
is licensed under the MIT License