Created
February 13, 2012 23:19
-
-
Save jamesu/1821383 to your computer and use it in GitHub Desktop.
Reading Tribes 1 dts files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# Basic attempt at reading Tribes 1 .dts files | |
# Appears to be some sort of nested IFF-like block format | |
File.open(ARGV[0]) do |f| | |
pos = 0 | |
while !f.eof | |
f.seek pos | |
magic = f.read(4).unpack("L<")[0] | |
if magic != 0x53524550 # PERS | |
pos += 1 | |
next | |
end | |
size, namesize = f.read(4+2).unpack("L<S<") | |
name = f.read(namesize) | |
puts "BLOCK: #{name} @ #{pos} [#{size} bytes]" | |
pos += 4+4+2+namesize # Skip this block header | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment