pgtools 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +25 -0
  3. data/bin/bxm_decoder +2 -0
  4. data/bin/bxm_encoder +2 -0
  5. data/bin/clh_convert +2 -0
  6. data/bin/clp_convert +2 -0
  7. data/bin/clw_convert +2 -0
  8. data/bin/dat_creator +2 -0
  9. data/bin/dat_extractor +2 -0
  10. data/bin/dat_ls +2 -0
  11. data/bin/eff_idd_creator +2 -0
  12. data/bin/eff_idd_extractor +2 -0
  13. data/bin/exp_convert_wiiu_pc +2 -0
  14. data/bin/exp_tool +2 -0
  15. data/bin/mot_convert_wiiu_pc +2 -0
  16. data/bin/mot_tool +2 -0
  17. data/bin/pkz_extractor +2 -0
  18. data/bin/scr_creator +2 -0
  19. data/bin/scr_extractor +2 -0
  20. data/bin/wmb_cleanup +2 -0
  21. data/bin/wmb_common_bones +2 -0
  22. data/bin/wmb_convert_pc_switch +2 -0
  23. data/bin/wmb_convert_wiiu_pc +2 -0
  24. data/bin/wmb_export_assimp +2 -0
  25. data/bin/wmb_get_bone_map +2 -0
  26. data/bin/wmb_import_assimp +2 -0
  27. data/bin/wmb_import_nier +2 -0
  28. data/bin/wmb_import_wiiu +2 -0
  29. data/bin/wtb_convert_wiiu_pc +2 -0
  30. data/bin/wtx_creator +2 -0
  31. data/bin/wtx_extractor +2 -0
  32. data/lib/bayonetta/alignment.rb +14 -0
  33. data/lib/bayonetta/bone.rb +55 -0
  34. data/lib/bayonetta/bxm.rb +180 -0
  35. data/lib/bayonetta/clh.rb +159 -0
  36. data/lib/bayonetta/clp.rb +212 -0
  37. data/lib/bayonetta/clw.rb +166 -0
  38. data/lib/bayonetta/dat.rb +261 -0
  39. data/lib/bayonetta/eff.rb +314 -0
  40. data/lib/bayonetta/endianness.rb +53 -0
  41. data/lib/bayonetta/exp.rb +768 -0
  42. data/lib/bayonetta/linalg.rb +416 -0
  43. data/lib/bayonetta/material_database.yaml +2581 -0
  44. data/lib/bayonetta/mot.rb +763 -0
  45. data/lib/bayonetta/pkz.rb +63 -0
  46. data/lib/bayonetta/scr.rb +393 -0
  47. data/lib/bayonetta/tools/bxm_decoder.rb +23 -0
  48. data/lib/bayonetta/tools/bxm_encoder.rb +37 -0
  49. data/lib/bayonetta/tools/clh_convert.rb +60 -0
  50. data/lib/bayonetta/tools/clp_convert.rb +70 -0
  51. data/lib/bayonetta/tools/clw_convert.rb +60 -0
  52. data/lib/bayonetta/tools/dat_creator.rb +57 -0
  53. data/lib/bayonetta/tools/dat_extractor.rb +94 -0
  54. data/lib/bayonetta/tools/dat_ls.rb +106 -0
  55. data/lib/bayonetta/tools/eff_idd_creator.rb +66 -0
  56. data/lib/bayonetta/tools/eff_idd_extractor.rb +73 -0
  57. data/lib/bayonetta/tools/exp_convert_wiiu_pc.rb +33 -0
  58. data/lib/bayonetta/tools/exp_tool.rb +48 -0
  59. data/lib/bayonetta/tools/mot_convert_wiiu_pc.rb +33 -0
  60. data/lib/bayonetta/tools/mot_tool.rb +60 -0
  61. data/lib/bayonetta/tools/pkz_extractor.rb +75 -0
  62. data/lib/bayonetta/tools/scr_creator.rb +63 -0
  63. data/lib/bayonetta/tools/scr_extractor.rb +78 -0
  64. data/lib/bayonetta/tools/wmb_cleanup.rb +250 -0
  65. data/lib/bayonetta/tools/wmb_common_bones.rb +45 -0
  66. data/lib/bayonetta/tools/wmb_convert_pc_switch.rb +35 -0
  67. data/lib/bayonetta/tools/wmb_convert_wiiu_pc.rb +33 -0
  68. data/lib/bayonetta/tools/wmb_export_assimp.rb +479 -0
  69. data/lib/bayonetta/tools/wmb_get_bone_map.rb +50 -0
  70. data/lib/bayonetta/tools/wmb_import_assimp.rb +735 -0
  71. data/lib/bayonetta/tools/wmb_import_geometry_wiiu_pc.rb +472 -0
  72. data/lib/bayonetta/tools/wmb_import_nier.rb +309 -0
  73. data/lib/bayonetta/tools/wtb_convert_wiiu_pc.rb +95 -0
  74. data/lib/bayonetta/tools/wtb_import_textures.rb +103 -0
  75. data/lib/bayonetta/tools/wtx_creator.rb +69 -0
  76. data/lib/bayonetta/tools/wtx_extractor.rb +85 -0
  77. data/lib/bayonetta/vertex_types.yaml +213 -0
  78. data/lib/bayonetta/vertex_types2.yaml +164 -0
  79. data/lib/bayonetta/vertex_types_nier.yaml +145 -0
  80. data/lib/bayonetta/wmb.rb +2443 -0
  81. data/lib/bayonetta/wmb3.rb +759 -0
  82. data/lib/bayonetta/wtb.rb +481 -0
  83. data/lib/bayonetta.rb +60 -0
  84. metadata +254 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7e36398b3fbef0f7e869fce605df24a9cd6e22ac5c6b391f49254474d129d942
4
+ data.tar.gz: 92d27315789a8c08f6dcefa721bf32a1af992bb4b848e1597b402494208bbe5e
5
+ SHA512:
6
+ metadata.gz: 904a07ac609d5d594d80f94e9611dd48ac747dca93407188081e1e678b82a0084592d039cfbad5082670223e09a068ae844fd2b536b148fcad6ace8eb54f2a62
7
+ data.tar.gz: 2767aca08e04ec6a22de97726bd482c59d90aeea08349a102902139c80e6168ab5032443d043da2664c519be935714f4293dc77900c615d7cdbc7e7d07e60d2e
data/LICENSE ADDED
@@ -0,0 +1,25 @@
1
+ BSD 2-Clause License
2
+
3
+ Copyright (c) 2017-2021, Brice Videau
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ * Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ * Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/bin/bxm_decoder ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bayonetta/tools/bxm_decoder'
data/bin/bxm_encoder ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bayonetta/tools/bxm_encoder'
data/bin/clh_convert ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bayonetta/tools/clh_convert'
data/bin/clp_convert ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bayonetta/tools/clp_convert'
data/bin/clw_convert ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bayonetta/tools/clw_convert'
data/bin/dat_creator ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bayonetta/tools/dat_creator'
data/bin/dat_extractor ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bayonetta/tools/dat_extractor'
data/bin/dat_ls ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bayonetta/tools/dat_ls'
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bayonetta/tools/eff_idd_creator'
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bayonetta/tools/eff_idd_extractor'
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bayonetta/tools/exp_convert_wiiu_pc'
data/bin/exp_tool ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bayonetta/tools/exp_tool'
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bayonetta/tools/mot_convert_wiiu_pc'
data/bin/mot_tool ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bayonetta/tools/mot_tool'
data/bin/pkz_extractor ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bayonetta/tools/pkz_extractor'
data/bin/scr_creator ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bayonetta/tools/scr_creator'
data/bin/scr_extractor ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bayonetta/tools/scr_extractor'
data/bin/wmb_cleanup ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bayonetta/tools/wmb_cleanup'
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bayonetta/tools/wmb_common_bones'
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bayonetta/tools/wmb_convert_pc_switch'
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bayonetta/tools/wmb_convert_wiiu_pc'
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bayonetta/tools/wmb_export_assimp'
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bayonetta/tools/wmb_get_bone_map'
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bayonetta/tools/wmb_import_assimp'
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bayonetta/tools/wmb_import_nier'
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bayonetta/tools/wmb_import_geometry_wiiu_pc'
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bayonetta/tools/wtb_convert_wiiu_pc'
data/bin/wtx_creator ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bayonetta/tools/wtx_creator'
data/bin/wtx_extractor ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bayonetta/tools/wtx_extractor'
@@ -0,0 +1,14 @@
1
+ module Bayonetta
2
+
3
+ module Alignment
4
+
5
+ def align(val, alignment)
6
+ remainder = val % alignment
7
+ val += alignment - remainder if remainder > 0
8
+ val
9
+ end
10
+ private :align
11
+
12
+ end
13
+
14
+ end
@@ -0,0 +1,55 @@
1
+ module Bayonetta
2
+
3
+ class Bone
4
+ attr_accessor :parent
5
+ attr_accessor :children
6
+ attr_accessor :index
7
+ attr_accessor :position
8
+ attr_accessor :relative_position
9
+ attr_accessor :symmetric
10
+ attr_accessor :flag
11
+ def initialize( position )
12
+ @position = position
13
+ @children = []
14
+ @parent = nil
15
+ @relative_position = nil
16
+ @symmetric = nil
17
+ @flag = nil
18
+ @index = nil
19
+ end
20
+
21
+ def depth
22
+ if parent then
23
+ return parent.depth + 1
24
+ else
25
+ return 0
26
+ end
27
+ end
28
+
29
+ def to_s
30
+ "<#{@index}#{@parent ? " (#{@parent.index})" : ""}: #{@position.x}, #{@position.y}, #{@position.z}, d: #{depth}>"
31
+ end
32
+
33
+ def inspect
34
+ to_s
35
+ end
36
+
37
+ def distance(other)
38
+ d = (@position.x - other.position.x)**2 +
39
+ (@position.y - other.position.y)**2 +
40
+ (@position.z - other.position.z)**2
41
+ d = Math::sqrt(d)
42
+ dd = (depth - other.depth).abs
43
+ [d, dd]
44
+ end
45
+
46
+ def parents
47
+ return [] unless parent
48
+ return [parent] + parent.parents
49
+ end
50
+
51
+ end
52
+
53
+ end
54
+
55
+
@@ -0,0 +1,180 @@
1
+ require 'nokogiri'
2
+ require 'set'
3
+
4
+ module Bayonetta
5
+ #=begin
6
+ class BXMFile < LibBin::Structure
7
+
8
+ class Datum < LibBin::Structure
9
+ uint16 :name_offset
10
+ int16 :value_offset
11
+ end
12
+
13
+ class Node < LibBin::Structure
14
+ uint16 :child_count
15
+ uint16 :first_child_index
16
+ uint16 :attribute_count
17
+ uint16 :datum_index
18
+ end
19
+
20
+ class Header < LibBin::Structure
21
+ string :id, 4
22
+ uint32 :unknown
23
+ uint16 :node_count
24
+ uint16 :datum_count
25
+ uint32 :data_size
26
+ end
27
+
28
+ register_field :header, Header
29
+ register_field :nodes, Node, count: 'header\node_count'
30
+ register_field :datums, Datum, count: 'header\datum_count'
31
+ string :data, 'header\data_size'
32
+
33
+ def get_data_strings
34
+ io = StringIO::new(data, "rb")
35
+ pos = 0
36
+ data_strings = {-1 => nil}
37
+ while (l = io.gets("\0"))
38
+ data_strings[pos] = l.unpack("Z*").first
39
+ pos = io.tell
40
+ end
41
+ data_strings
42
+ end
43
+
44
+ def get_datas
45
+ data_strings = get_data_strings
46
+ datums.collect { |d| [data_strings[d.name_offset], data_strings[d.value_offset]] }
47
+ end
48
+
49
+ def build_xml_tree(doc, index, datas)
50
+ node = nodes[index]
51
+ name, value = datas[node.datum_index]
52
+ n = Nokogiri::XML::Node.new(name, doc)
53
+ n.content = value if value
54
+ node.attribute_count.times { |i|
55
+ name, value = datas[node.datum_index + i + 1]
56
+ n[name] = value
57
+ }
58
+ node.child_count.times { |i|
59
+ n << build_xml_tree(doc, node.first_child_index + i, datas)
60
+ }
61
+ n
62
+ end
63
+
64
+ def to_xml
65
+ datas = get_datas
66
+ doc = Nokogiri::XML::Document::new
67
+ doc << build_xml_tree(doc, 0, datas) if header.node_count > 0
68
+ doc
69
+ end
70
+
71
+ def process_node(node, index, next_node_index)
72
+ name = node.name
73
+ children = node.elements
74
+ value = node.content if children.empty?
75
+ value = value.strip if value
76
+ value = nil if value == ''
77
+ attributes = node.attributes
78
+
79
+ n = Node.new
80
+ n.child_count = children.size
81
+ n.first_child_index = next_node_index
82
+ n.attribute_count = attributes.size
83
+ nodes[index] = n
84
+
85
+ node_datums = [[name, value]]
86
+ attributes.each { |k, v| node_datums.push [k, v.value] }
87
+ datum_index = datums.each_cons(node_datums.size).find_index { |sub| sub == node_datums }
88
+ if datum_index
89
+ n.datum_index = datum_index
90
+ else
91
+ n.datum_index = datums.size
92
+ datums.push *node_datums
93
+ node_datums.flatten.each { |v| data.add v if v }
94
+ end
95
+ next_node_index += children.size
96
+ children.each_with_index { |c, i|
97
+ next_node_index = process_node(c, n.first_child_index + i, next_node_index)
98
+ }
99
+ next_node_index
100
+ end
101
+
102
+ def from_xml(xml, tag)
103
+ @header = Header.new
104
+ @nodes = []
105
+ @datums = []
106
+ @data = Set.new
107
+ header.id = tag
108
+ header.unknown = 0
109
+ process_node(xml.children.first, 0, 1)
110
+ header.node_count = nodes.length
111
+ header.datum_count = datums.length
112
+ io = StringIO::new("", "wb")
113
+ data_map = data.collect { |d|
114
+ pos = io.tell
115
+ io.write(d, "\0")
116
+ [d, pos]
117
+ }.to_h
118
+ data_map[nil] = -1
119
+ datums.collect! { |n, v|
120
+ d = Datum.new
121
+ d.name_offset = data_map[n]
122
+ d.value_offset = data_map[v]
123
+ d
124
+ }
125
+ @data = io.string
126
+ header.data_size = data.bytesize
127
+ self
128
+ end
129
+
130
+ def self.from_xml(xml, tag="BXM\x00".b)
131
+ bxm = self.new
132
+ bxm.from_xml(xml, tag)
133
+ end
134
+
135
+ def self.is_big?(f)
136
+ true
137
+ end
138
+
139
+ def self.load(input_name)
140
+ if input_name.respond_to?(:read) && input_name.respond_to?(:seek)
141
+ input = input_name
142
+ else
143
+ File.open(input_name, "rb") { |f|
144
+ input = StringIO::new(f.read, "rb")
145
+ }
146
+ end
147
+ tag = input.read(4).unpack("a4").first
148
+ raise "invalid file type #{tag}!" if tag != "XML\x00".b && tag != "BXM\x00".b
149
+ input.rewind
150
+ bxm = self.new
151
+ big = input_big = is_big?(input)
152
+ bxm.instance_variable_set(:@__was_big, big)
153
+ bxm.__load(input, big)
154
+ input.close unless input_name.respond_to?(:read) && input_name.respond_to?(:seek)
155
+ bxm
156
+ end
157
+
158
+ def dump(output_name, output_big = true)
159
+ if output_name.respond_to?(:write) && output_name.respond_to?(:seek)
160
+ output = output_name
161
+ else
162
+ output = StringIO::new("".b, "wb")
163
+ end
164
+
165
+ __set_dump_state(output, output_big, nil, nil)
166
+ __dump_fields
167
+ __unset_dump_state
168
+
169
+ unless output_name.respond_to?(:write) && output_name.respond_to?(:seek)
170
+ File.open(output_name, "wb") { |f|
171
+ f.write output.string
172
+ }
173
+ output.close
174
+ end
175
+ self
176
+ end
177
+
178
+ end
179
+
180
+ end
@@ -0,0 +1,159 @@
1
+ module Bayonetta
2
+
3
+ class CLHFile < LibBin::Structure
4
+
5
+ class FVector < LibBin::Structure
6
+ float :x
7
+ float :y
8
+ float :z
9
+
10
+ def from_bxm_vector(v)
11
+ @x, @y, @z = v.split(" ").collect(&:to_f)
12
+ self
13
+ end
14
+
15
+ def self.from_bxm_vector(v)
16
+ nv = self::new
17
+ nv.from_bxm_vector(v)
18
+ nv
19
+ end
20
+
21
+ end
22
+
23
+ class ClothAT < LibBin::Structure
24
+ int16 :p1
25
+ int16 :p2
26
+ float :weight
27
+ float :radius
28
+ register_field :offset1, FVector
29
+ register_field :offset2, FVector
30
+
31
+ def from_bxm_cloth_at(h)
32
+ @p1 = h.at_css("p1").content.to_i
33
+ @p2 = h.at_css("p2").content.to_i
34
+ @weight = h.at_css("weight").content.to_f
35
+ @radius = h.at_css("radius").content.to_f
36
+ @offset1 = FVector.from_bxm_vector(h.at_css("offset1").content)
37
+ @offset2 = FVector.from_bxm_vector(h.at_css("offset2").content)
38
+ self
39
+ end
40
+
41
+ def self.from_bxm_cloth_at(c)
42
+ clat = self::new
43
+ clat.from_bxm_cloth_at(c)
44
+ clat
45
+ end
46
+
47
+ def remap(map)
48
+ @p1 = check_and_remap_bone(map, @p1)
49
+ @p2 = check_and_remap_bone(map, @p2)
50
+ end
51
+
52
+ private
53
+ def check_and_remap_bone(map, no)
54
+ tmp = map[no]
55
+ raise "No bone found in map for #{no}!" unless tmp
56
+ tmp
57
+ end
58
+
59
+ end
60
+
61
+ int32 :cloth_at_num
62
+ register_field :cloth_at, ClothAT, count: 'cloth_at_num'
63
+
64
+ def was_big?
65
+ @__was_big
66
+ end
67
+
68
+ def remap(map)
69
+ @cloth_at.each { |c|
70
+ c.remap(map)
71
+ }
72
+ end
73
+
74
+ def self.load_bxm(input_name)
75
+ bxm = BXMFile::load(input_name)
76
+ clat = self::new
77
+
78
+ doc = bxm.to_xml
79
+ clat.cloth_at_num = doc.at_css("//CLOTH_AT//CLOTH_AT_NUM").content.to_i
80
+
81
+ clat.cloth_at = doc.css("//CLOTH_AT//CLOTH_AT_WK").collect { |c|
82
+ ClothAT.from_bxm_cloth_at(c)
83
+ }
84
+ clat
85
+ end
86
+
87
+ def self.is_big?(f)
88
+ f.rewind
89
+ f.size
90
+ block = lambda { |int|
91
+ num = f.read(4).unpack(int).first
92
+ ( num >= 0 ) && ( num < 256 )
93
+ }
94
+ big = block.call("l>")
95
+ f.rewind
96
+ small = block.call("l<")
97
+ f.rewind
98
+ raise "Invalid data!" unless big ^ small
99
+ return big
100
+ end
101
+
102
+ def self.convert(input_name, output_name, output_big = false)
103
+ if input_name.respond_to?(:read) && input_name.respond_to?(:seek)
104
+ input = input_name
105
+ else
106
+ input = File.open(input_name, "rb")
107
+ end
108
+ input_big = is_big?(input)
109
+
110
+ if output_name.respond_to?(:write) && output_name.respond_to?(:seek)
111
+ output = output_name
112
+ else
113
+ output = File.open(output_name, "wb")
114
+ end
115
+ output.rewind
116
+
117
+ clp = self::new
118
+ clp.instance_variable_set(:@__was_big, input_big)
119
+ clp.__convert(input, output, input_big, output_big)
120
+
121
+ input.close unless input_name.respond_to?(:read) && input_name.respond_to?(:seek)
122
+ output.close unless output_name.respond_to?(:write) && output_name.respond_to?(:seek)
123
+ clp
124
+ end
125
+
126
+ def self.load(input_name)
127
+ if input_name.respond_to?(:read) && input_name.respond_to?(:seek)
128
+ input = input_name
129
+ else
130
+ input = File.open(input_name, "rb")
131
+ end
132
+ input_big = is_big?(input)
133
+
134
+ clp = self::new
135
+ clp.instance_variable_set(:@__was_big, input_big)
136
+ clp.__load(input, input_big)
137
+ input.close unless input_name.respond_to?(:read) && input_name.respond_to?(:seek)
138
+ clp
139
+ end
140
+
141
+ def dump(output_name, output_big = false)
142
+ if output_name.respond_to?(:write) && output_name.respond_to?(:seek)
143
+ output = output_name
144
+ else
145
+ output = File.open(output_name, "wb")
146
+ end
147
+ output.rewind
148
+
149
+ __set_dump_state(output, output_big, nil, nil)
150
+ __dump_fields
151
+ __unset_dump_state
152
+
153
+ output.close unless output_name.respond_to?(:write) && output_name.respond_to?(:seek)
154
+ self
155
+ end
156
+
157
+ end
158
+
159
+ end