@@ -20,7 +20,7 @@ class Rucksack
20
20
DATA_FILE = Process .executable_path.not_nil!
21
21
MODE = ENV .fetch(" RUCKSACK_MODE" , " 0" ).to_i
22
22
23
- @@offset : UInt64 = 0
23
+ @@offset : Int64 = 0
24
24
@@index = {} of String => File
25
25
26
26
def self.offset
@@ -70,7 +70,7 @@ class Rucksack
70
70
71
71
raise RucksackEmpty .new(" Rucksack is empty, did you pack any files?" ) if offset + 2 > eof
72
72
73
- file_offset : UInt64 = 0 .to_u64
73
+ file_offset : Int64 = 0 .to_i64
74
74
::File .open(Process .executable_path.not_nil!) do |fd |
75
75
fd.seek(offset)
76
76
loop do
@@ -79,7 +79,7 @@ class Rucksack
79
79
path = Bytes .new(path_len)
80
80
fd.read(path)
81
81
82
- size = fd.read_bytes(UInt64 , IO ::ByteFormat ::LittleEndian )
82
+ size = fd.read_bytes(Int64 , IO ::ByteFormat ::LittleEndian )
83
83
fd.seek(offset + file_offset + 2 + path_len + 8 + size)
84
84
85
85
body_digest = Bytes .new(32 )
@@ -153,7 +153,7 @@ class Rucksack
153
153
abstract class File
154
154
abstract def read (io : IO , skip_verify = false )
155
155
abstract def path : String
156
- abstract def size : UInt64
156
+ abstract def size : Int64
157
157
abstract def checksum : Slice (UInt8 )
158
158
end
159
159
@@ -177,17 +177,17 @@ class Rucksack
177
177
c.final
178
178
end
179
179
180
- def size : UInt64
180
+ def size : Int64
181
181
::File .size(@path )
182
182
end
183
183
end
184
184
185
185
class RucksackFile < File
186
186
getter path : String
187
187
getter checksum : Slice (UInt8 )
188
- getter size : UInt64
188
+ getter size : Int64
189
189
190
- def initialize (@path , @offset : UInt64 , @size , @checksum )
190
+ def initialize (@path , @offset : Int64 , @size , @checksum )
191
191
@verified = false
192
192
end
193
193
@@ -217,7 +217,7 @@ macro rucksack(path)
217
217
{{
218
218
system(<<-EOC
219
219
cat >#{ __DIR__ } /.rucksack_packer.cr <<EOF
220
- require "openssl "
220
+ require "digest "
221
221
222
222
EOF_DELIM = "RS".to_slice
223
223
@@ -233,7 +233,7 @@ dst = File.open(".rucksack", "a")
233
233
src = File.open ARGV[0]
234
234
size = src.size
235
235
236
- dio = OpenSSL::DigestIO .new(dst, " SHA256" , mode: OpenSSL::DigestIO ::DigestMode::Write)
236
+ dio = IO::Digest .new(dst, Digest:: SHA256.new , mode: IO::Digest ::DigestMode::Write)
237
237
238
238
dst.write_bytes ARGV[0].size.to_u16, IO::ByteFormat::LittleEndian
239
239
dst.write(ARGV[0].to_slice)
@@ -242,7 +242,7 @@ dst.write_bytes size.to_u64, IO::ByteFormat::LittleEndian
242
242
243
243
bytes_copied = IO.copy(src, dio)
244
244
245
- dst.write(dio.digest )
245
+ dst.write(dio.final )
246
246
dst.write(EOF_DELIM)
247
247
248
248
if bytes_copied != size
0 commit comments