Skip to content

Instantly share code, notes, and snippets.

@jamesu
Created February 13, 2012 23:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesu/1821383 to your computer and use it in GitHub Desktop.
Save jamesu/1821383 to your computer and use it in GitHub Desktop.
Reading Tribes 1 dts files
#!/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