xtminfo : Removed XtmHeader from xtminfo script.
This commit is contained in:
parent
90da6659c7
commit
d9bc8a3555
1 changed files with 11 additions and 59 deletions
70
bin/xtminfo
70
bin/xtminfo
|
@ -1,64 +1,15 @@
|
|||
#!/usr/bin/ruby -d
|
||||
#!/usr/bin/ruby
|
||||
|
||||
require 'optparse'
|
||||
|
||||
require 'rubygems'
|
||||
require 'bindata'
|
||||
|
||||
class XtmHeader < BinData::Record
|
||||
# Offset Information Taille (octets)
|
||||
# 0 Longueur du nom du programme 1
|
||||
# 1 *Nom du programme 20
|
||||
# 21 Longueur de la version 1
|
||||
# 22 Version 4
|
||||
# 26 Not used 10
|
||||
# 36 Date 4
|
||||
# 40 Longueur du nom du fichier original 1
|
||||
# 41 Nom du fichier original 50
|
||||
# 91 **Hash MD5 1
|
||||
# 92 Nombre de fichiers 4
|
||||
# 96 Taille du fichier original 8
|
||||
require 'xtmfile/xtmheader'
|
||||
|
||||
endian :little
|
||||
|
||||
uint8 :progname_len, :value => lambda { progname_str.length }
|
||||
string :progname_str, :length => 20
|
||||
|
||||
uint8 :version_len, :value => lambda { version_str.length }
|
||||
string :version_str, :length => 4
|
||||
|
||||
string :unused, :length => 10
|
||||
|
||||
uint32le :date
|
||||
|
||||
uint8 :filename_len
|
||||
stringz :filename_str, :length => 50
|
||||
string :filename_str_pad, :length => lambda { 50 - filename_len - 1 }
|
||||
|
||||
uint8 :md5
|
||||
|
||||
uint32 :filecount
|
||||
uint64 :filesize
|
||||
|
||||
def to_s
|
||||
r = []
|
||||
r << ( "Progname len : %s [%s]" % [self.progname_len, self.progname_len.offset] )
|
||||
r << ( "Progname str : %s [%s]" % [self.progname_str, self.progname_str.offset] )
|
||||
r << ( " Version len : %s [%s]" % [self.version_len, self.version_len.offset] )
|
||||
r << ( " Version str : %s [%s]" % [self.version_str, self.version_str.offset] )
|
||||
r << ( " Unused : %s [%s]" % [self.unused, self.unused.offset] )
|
||||
r << ( " Date : %s [%s]" % [self.date, self.date.offset] )
|
||||
r << ( "Filename len : %s [%s]" % [self.filename_len, self.filename_len.offset] )
|
||||
r << ( "Filename str : %s [%s]" % [self.filename_str, self.filename_str.offset] )
|
||||
r << ( " md5 : %s [%s]" % [self.md5, self.md5.offset] )
|
||||
r << ( " Filecount : %d [%s]" % [self.filecount, self.filecount.offset] )
|
||||
r << ( " Filesize : %s [%s]" % [self.filesize, self.filesize.offset] )
|
||||
return r.join("\n")
|
||||
end
|
||||
end
|
||||
|
||||
class XtmJoin
|
||||
class XtmJoinArgumentError < ArgumentError ; end
|
||||
class XtmInfo
|
||||
class XtmInfoArgumentError < ArgumentError ; end
|
||||
|
||||
attr_reader :opts
|
||||
|
||||
|
@ -72,10 +23,10 @@ class XtmJoin
|
|||
def parse_command_line args
|
||||
@args = args.clone
|
||||
@opts = OptionParser.new do |opts|
|
||||
opts.banner = "Usage: #{File.basename $0} [action] [options]\n"
|
||||
opts.banner = "Usage: #{File.basename $0} [options]\n"
|
||||
|
||||
opts.separator ""
|
||||
opts.separator "Actions:"
|
||||
opts.separator "Mandatory options"
|
||||
|
||||
opts.on("-i", "--input FILE", "Input XTM file") do |r|
|
||||
@input_xtm = r
|
||||
|
@ -90,13 +41,14 @@ class XtmJoin
|
|||
opts.on("-v", "--verbose", "Show warnings too") do |v|
|
||||
@verbose = v
|
||||
end
|
||||
opts.separator ""
|
||||
end
|
||||
end
|
||||
|
||||
def validate!
|
||||
@opts.parse!
|
||||
|
||||
raise XtmJoinArgumentError, "No input XTM file specified!" if @input_xtm.nil?
|
||||
raise XtmInfoArgumentError, "No input XTM file specified!" if @input_xtm.nil?
|
||||
end
|
||||
|
||||
|
||||
|
@ -112,10 +64,10 @@ class XtmJoin
|
|||
def self.main args
|
||||
xj = nil
|
||||
begin
|
||||
xj = XtmJoin.new args
|
||||
xj = XtmInfo.new args
|
||||
xj.run
|
||||
exit 0
|
||||
rescue XtmJoinArgumentError => e
|
||||
rescue XtmInfoArgumentError => e
|
||||
STDERR.puts "%s" % xj.opts
|
||||
STDERR.puts "error: %s" % e.message
|
||||
|
||||
|
@ -129,4 +81,4 @@ class XtmJoin
|
|||
end
|
||||
end
|
||||
|
||||
XtmJoin.main ARGV
|
||||
XtmInfo.main ARGV
|
||||
|
|
Loading…
Reference in a new issue