EXtremeZip 2022.1.15 → 2022.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/extremeunzip.zzaqsu.rb +45 -60
- data/lib/extremezip.zzaqsv.rb +59 -10
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d368c2ced983111e5abca75f712fd09f01f9a3c308860782ce9d17850aa84b9d
|
4
|
+
data.tar.gz: 8d9c5b14cd143fec9be4a4149b4ba191665bbdaab6e30c3de9492eb3183c5839
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 249baeec68ad080d1d4fbd7f158d11b794aeff51c4e429d447cea91c9e9cb925a0c487506b9112e1cccf530bfe325f1dd5c74b1914d63a53a972a592acbf00a2
|
7
|
+
data.tar.gz: 229d12c536bc4ecec1253e62bb98db4a9cba42f0808904bd36ad9460dcb801ad949dc33c2ac39ac4c0982d37d2248d28d73e1a0943a3d61ad1547238cdc21187
|
data/lib/extremeunzip.zzaqsu.rb
CHANGED
@@ -1,20 +1,47 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
# require 'pathname'
|
4
|
-
# require File.dirname(__FILE__)+'/filemessage.pb.rb'
|
5
3
|
require 'victoriafresh'
|
6
4
|
require 'cbor'
|
7
5
|
require 'lzma'
|
8
6
|
require 'get_process_mem'
|
9
7
|
|
10
8
|
def checkMemoryUsage(lineNumber)
|
11
|
-
|
9
|
+
mem = GetProcessMem.new
|
12
10
|
|
13
|
-
|
11
|
+
puts("#{lineNumber} , Memory: #{mem.mb}"); # Debug
|
14
12
|
end # def checkMemoryUsage
|
15
13
|
|
16
|
-
|
17
|
-
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
class ExtremeUnZip
|
18
|
+
# 根据偏移值来读取压缩块数据列表。
|
19
|
+
def readVfsDataList(wholeCbor)
|
20
|
+
compressedVfsDataList = [] # 获取压缩后的数据块列表
|
21
|
+
startIndix=wholeCbor['vfsDataListStart'] # 初始起始位置。
|
22
|
+
|
23
|
+
puts "whole length: #{@wholeFileContent.length}, list conent: #{wholeCbor['vfsDataList']}" # Debug
|
24
|
+
|
25
|
+
|
26
|
+
wholeCbor['vfsDataList'].each do |currentBlockInfo| # 一个个块地处理
|
27
|
+
length=currentBlockInfo['length'] # 获取长度。
|
28
|
+
|
29
|
+
currentBlock=@wholeFileContent[startIndix, length] # 读取内容
|
30
|
+
|
31
|
+
puts "start index: #{startIndix}, length: #{length}, content length: #{currentBlock.length}" # Debug
|
32
|
+
|
33
|
+
compressedVfsDataList << currentBlock # 加入当前块
|
34
|
+
|
35
|
+
startIndix+=length # 位移。
|
36
|
+
end
|
37
|
+
|
38
|
+
compressedVfsDataList # 返回 内容
|
39
|
+
end
|
40
|
+
|
41
|
+
# 根据版本号,提取VFS数据内容
|
42
|
+
|
43
|
+
|
44
|
+
def extractVfsDataWithVersionExternalFile(wholeCbor, fileVersion)
|
18
45
|
victoriaFreshData = '' # 解压后的数据块整体
|
19
46
|
dataFileName = 'victoriafreshdata.w' # 数据文件名
|
20
47
|
dataFile = {} # 数据文件对象
|
@@ -31,6 +58,10 @@ def extractVfsDataWithVersionExternalFile(wholeCbor, fileVersion)
|
|
31
58
|
dataFile.close # 关闭文件
|
32
59
|
elsif (fileVersion >= 30) # 30以上版本
|
33
60
|
compressedVfsDataList = wholeCbor['vfsDataList'] # 获取压缩后的数据块列表
|
61
|
+
|
62
|
+
if (fileVersion>=251) # 251 以上版本。要按照偏移值来读取压缩数据块列表。
|
63
|
+
compressedVfsDataList=readVfsDataList(wholeCbor) # 根据偏移值来读取压缩块数据列表。
|
64
|
+
end # if (fileVersion>=251) # 251 以上版本
|
34
65
|
|
35
66
|
puts("data block amont: #{compressedVfsDataList.length}") # Debug
|
36
67
|
|
@@ -44,18 +75,12 @@ def extractVfsDataWithVersionExternalFile(wholeCbor, fileVersion)
|
|
44
75
|
|
45
76
|
begin # 解压
|
46
77
|
currentRawData = LZMA.decompress(currentCompressed) # 解压这一块
|
47
|
-
|
48
78
|
|
49
79
|
dataFile.syswrite(currentRawData) # 写入内容
|
50
80
|
rescue RuntimeError => e # 解压失败
|
51
81
|
puts "Warning: the exz file may be incomplete." # 报告错误。文件可能不完整。
|
52
82
|
end # begin # 解压
|
53
83
|
|
54
|
-
# victoriaFreshData=victoriaFreshData+currentRawData #追加
|
55
|
-
# victoriaFreshData << currentRawData #追加
|
56
|
-
|
57
|
-
#puts("byte size: #{victoriaFreshData.bytesize}") # debug.
|
58
|
-
|
59
84
|
dataBlockCounter += 1 # count
|
60
85
|
end # compressedVfsDataList.each do |currentCompressed|
|
61
86
|
|
@@ -65,54 +90,21 @@ def extractVfsDataWithVersionExternalFile(wholeCbor, fileVersion)
|
|
65
90
|
dataFileName # 返回解压后的数据块整体
|
66
91
|
end # def extractVfsDataWithVersionExternalFile(wholeCbor, fileVersion) #根据版本号,提取VFS数据内容
|
67
92
|
|
68
|
-
|
69
|
-
victoriaFreshData = '' # 解压后的数据块整体
|
70
|
-
|
71
|
-
if (fileVersion == 14) # 14版本
|
72
|
-
compressedVfsData = wholeCbor['vfsData'] # 获取压缩后的数据内容
|
73
|
-
|
74
|
-
victoriaFreshData = LZMA.decompress(compressedVfsData) # 解压缩数据内容
|
75
|
-
elsif (fileVersion >= 30) # 30以上版本
|
76
|
-
compressedVfsDataList = wholeCbor['vfsDataList'] # 获取压缩后的数据块列表
|
77
|
-
|
78
|
-
puts("data block amont: #{compressedVfsDataList.length}") # Debug
|
79
|
-
|
80
|
-
dataBlockCounter = 0 # Data block counter
|
81
|
-
|
82
|
-
compressedVfsDataList.each do |currentCompressed| # 一块块地解压
|
83
|
-
puts("data block counter: #{dataBlockCounter}") # Debug
|
84
|
-
checkMemoryUsage(34)
|
85
|
-
|
86
|
-
currentRawData = LZMA.decompress(currentCompressed) # 解压这一块
|
87
|
-
|
88
|
-
# victoriaFreshData=victoriaFreshData+currentRawData #追加
|
89
|
-
victoriaFreshData << currentRawData # 追加
|
90
|
-
|
91
|
-
puts("byte size: #{victoriaFreshData.bytesize}") # debug.
|
92
|
-
|
93
|
-
dataBlockCounter += 1 # count
|
94
|
-
end # compressedVfsDataList.each do |currentCompressed|
|
95
|
-
end # if (fileVersion==14) #14版本
|
96
|
-
|
97
|
-
victoriaFreshData # 返回解压后的数据块整体
|
98
|
-
end # extractVfsDataWithVersion(wholeCbor, fileVersion) #根据版本号,提取VFS数据内容
|
99
|
-
|
100
|
-
class ExtremeUnZip
|
101
|
-
# 解压
|
93
|
+
# 解压
|
102
94
|
def exuz(rootPath)
|
103
95
|
result = true # 解压结果
|
104
96
|
|
105
|
-
|
97
|
+
currentBlockFile = File.new(rootPath, 'rb') # 打开文件
|
106
98
|
|
107
|
-
|
99
|
+
@wholeFileContent = currentBlockFile.read # 读取全部内容
|
108
100
|
|
109
|
-
|
101
|
+
currentBlockFile.close # 关闭文件
|
110
102
|
|
111
|
-
|
103
|
+
#@wholeFileContent = File.read(rootPath) # 最终文件内容
|
112
104
|
|
113
|
-
|
105
|
+
checkMemoryUsage(60)
|
114
106
|
|
115
|
-
|
107
|
+
wholeCborByteArray = @wholeFileContent[4..-1] # 从第5个到末尾
|
116
108
|
|
117
109
|
begin # 可能出错。
|
118
110
|
options = {:tolerant => true}
|
@@ -130,23 +122,16 @@ class ExtremeUnZip
|
|
130
122
|
checkMemoryUsage(90)
|
131
123
|
replyByteArray = LZMA.decompress(compressedVfsMenu) # 解码目录VFS字节数组内容
|
132
124
|
|
133
|
-
# puts replyByteArray #Debug
|
134
|
-
|
135
125
|
checkMemoryUsage(95)
|
136
|
-
|
126
|
+
|
137
127
|
victoriaFreshDataFile = extractVfsDataWithVersionExternalFile(wholeCbor, fileVersion) # 根据版本号,提取VFS数据内容
|
138
128
|
|
139
|
-
# puts victoriaFreshData #Debug
|
140
|
-
|
141
129
|
checkMemoryUsage(100)
|
142
130
|
$clipDownloader = VictoriaFresh.new # 创建下载器。
|
143
131
|
|
144
132
|
$clipDownloader.releaseFilesExternalDataFile(replyByteArray, victoriaFreshDataFile) # 释放各个文件
|
145
133
|
|
146
134
|
fileToRemove = File.new(victoriaFreshDataFile) # 要删除的文件
|
147
|
-
|
148
|
-
#File.delete(fileToRemove) # 删除文件
|
149
|
-
|
150
135
|
end # if (fileVersion<14) #版本号过小
|
151
136
|
|
152
137
|
result =true # 解压成功
|
data/lib/extremezip.zzaqsv.rb
CHANGED
@@ -48,10 +48,14 @@ class ExtremeZip
|
|
48
48
|
|
49
49
|
# 加入基本文件信息
|
50
50
|
def addBasicFileInformation
|
51
|
-
@wholeCbor['version'] =
|
51
|
+
@wholeCbor['version'] = 251 # 文件格式版本号
|
52
52
|
|
53
53
|
uuid = UUID.new # 获取生成器
|
54
54
|
@wholeCbor['uuid'] = uuid.generate # 指定本个压缩包的唯一编号
|
55
|
+
|
56
|
+
@wholeCbor['website']='https://rubygems.org/gems/EXtremeZip' # 加入网站地址
|
57
|
+
|
58
|
+
@wholeCbor['vfsDataListStart']=198910 # 压缩 VFS 数据列表起始位置。
|
55
59
|
end # addBasicFileInformation # 加入基本文件信息
|
56
60
|
|
57
61
|
# 压缩
|
@@ -72,10 +76,54 @@ class ExtremeZip
|
|
72
76
|
@wholeCbor['vfsDataList'] = @vfsDataList # 加入数据
|
73
77
|
|
74
78
|
wholeFileContent = 'exz' + "\0" + @wholeCbor.to_cbor # 追加CBOR字节数组
|
79
|
+
|
80
|
+
vfsDataListStart=wholeFileContent.length # 按照现在的序列化情况,计算出来的起始位置。
|
81
|
+
|
82
|
+
while (vfsDataListStart!=@wholeCbor['vfsDataListStart']) # 计算出的偏移不一致
|
83
|
+
@wholeCbor['vfsDataListStart']=vfsDataListStart # 使用新的值
|
84
|
+
wholeFileContent = 'exz' + "\0" + @wholeCbor.to_cbor # 追加CBOR字节数组
|
85
|
+
vfsDataListStart=wholeFileContent.length # 按照现在的序列化情况,计算出来的起始位置。
|
86
|
+
end
|
75
87
|
|
76
88
|
# 写入文件:
|
77
89
|
writeFile(wholeFileContent, victoriaFresh) # 写入文件内容
|
90
|
+
|
91
|
+
appendVfsDataList victoriaFresh # 追加压缩块列表数据。
|
78
92
|
end # def exz(rootPath)
|
93
|
+
|
94
|
+
# 写入压缩块文件
|
95
|
+
def writeCompressBlock(compressed, processCounter)
|
96
|
+
extremeZipOutputFile = File.new("comressed.#{processCounter}.cex", 'wb') # 创建文件
|
97
|
+
extremeZipOutputFile.syswrite(compressed) # 写入文件
|
98
|
+
extremeZipOutputFile.close # 关闭文件
|
99
|
+
end
|
100
|
+
|
101
|
+
# 追加压缩块列表数据。
|
102
|
+
def appendVfsDataList (victoriaFresh)
|
103
|
+
extremeZipOutputFile = File.new("#{victoriaFresh['name']}.exz", 'ab') # 打开文件
|
104
|
+
|
105
|
+
processCounter=0 # 块计数器。
|
106
|
+
|
107
|
+
@wholeCbor['vfsDataList'].each do
|
108
|
+
#extremeZipOutputFile = File.new("comressed.#{processCounter}.cex", 'wb') # 创建文件
|
109
|
+
|
110
|
+
currentBlockFile = File.new("comressed.#{processCounter}.cex", 'rb') # 打开文件
|
111
|
+
|
112
|
+
wholeFileContent = currentBlockFile.read # 读取全部内容
|
113
|
+
|
114
|
+
currentBlockFile.close # 关闭文件
|
115
|
+
|
116
|
+
#wholeFileContent=File.read("comressed.#{processCounter}.cex", 'rb') # 读取压缩块。
|
117
|
+
|
118
|
+
puts "wirte file contetn length: #{wholeFileContent.length}" # Debghu
|
119
|
+
|
120
|
+
extremeZipOutputFile.syswrite(wholeFileContent) # 写入文件
|
121
|
+
|
122
|
+
processCounter += 1 # 计数
|
123
|
+
end
|
124
|
+
|
125
|
+
extremeZipOutputFile.close # 关闭文件
|
126
|
+
end
|
79
127
|
|
80
128
|
# 写入文件内容
|
81
129
|
def writeFile(wholeFileContent, victoriaFresh)
|
@@ -92,8 +140,16 @@ class ExtremeZip
|
|
92
140
|
currentSubProcess=processIdList[processCounter] # 获取子进程对象
|
93
141
|
#processIdList.each do |currentSubProcess|
|
94
142
|
compressed = receiveFromSubProcess(currentSubProcess, responsePipeList, processCounter) # 从子进程中读取数据,并终止子进程
|
143
|
+
|
144
|
+
#写入当前压缩块到文件系统中去作为缓存。陈欣
|
145
|
+
writeCompressBlock(compressed, processCounter) # 写入压缩块文件
|
146
|
+
|
147
|
+
blockInfo={} # 块信息
|
148
|
+
blockInfo['length']=compressed.length # 记录长度
|
149
|
+
|
150
|
+
puts "block length: #{blockInfo['length']}" # Debug
|
95
151
|
|
96
|
-
@vfsDataList <<
|
152
|
+
@vfsDataList << blockInfo # 加入数据块列表中
|
97
153
|
checkMemoryUsage(150)
|
98
154
|
|
99
155
|
processCounter += 1 # 子进程计数
|
@@ -112,7 +168,7 @@ class ExtremeZip
|
|
112
168
|
|
113
169
|
currentBlockFile.close # 关闭文件
|
114
170
|
|
115
|
-
|
171
|
+
File.delete(currentBlockFile) # 删除数据块文件
|
116
172
|
|
117
173
|
currentBlockData
|
118
174
|
end
|
@@ -121,11 +177,8 @@ class ExtremeZip
|
|
121
177
|
def schedule1Block(filePartCounter)
|
122
178
|
currentBlockData = readBlockFile(filePartCounter) # 读取块文件内容
|
123
179
|
|
124
|
-
# currentTaskPipe = Cod.pipe # 任务分配管道
|
125
180
|
currentResponsePipe = Cod.pipe # 任务回复管道
|
126
181
|
|
127
|
-
puts("forking sub process, file part counter: #{filePartCounter}") # Debug.
|
128
|
-
|
129
182
|
p1 = fork do # 复制出子进程
|
130
183
|
compressInSubProcess(currentBlockData, currentResponsePipe) # 在子进程中具体执行的压缩代码
|
131
184
|
end # p1 = fork do #复制出子进程
|
@@ -146,11 +199,8 @@ class ExtremeZip
|
|
146
199
|
|
147
200
|
# 启动子进程。
|
148
201
|
def launchSubProcesses
|
149
|
-
|
150
|
-
#while ((@filePartCounter < @filePartAmount) && (true)) # 未处理完毕,并且未达到最大子进程个数
|
151
202
|
while ((@filePartCounter < @filePartAmount) && (@filePartCounter<@maxSubProcessAmount)) # 未处理完毕,并且未达到最大子进程个数
|
152
203
|
currentResponsePipe, p1 = schedule1Block(@filePartCounter) # 计划一个块的压缩计算
|
153
|
-
|
154
204
|
end # while processDataLength < victoriaFreshData.byte_size do #未处理完毕
|
155
205
|
|
156
206
|
[@processIdList, @responsePipeList]
|
@@ -168,7 +218,6 @@ class ExtremeZip
|
|
168
218
|
|
169
219
|
currentResponsePipe.put currentCompressedVfsData # 将压缩后的数据块写入到回复管道中
|
170
220
|
|
171
|
-
checkMemoryUsage(125)
|
172
221
|
puts("finished #{Process.pid}") # Debug
|
173
222
|
end # compressInSubProcess(currentBlockData, currentResponsePipe) # 在子进程中具体执行的压缩代码
|
174
223
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: EXtremeZip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2022.
|
4
|
+
version: 2022.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hxcan Cai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cod
|
@@ -86,20 +86,20 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 2022.1.
|
89
|
+
version: 2022.1.27
|
90
90
|
- - ">="
|
91
91
|
- !ruby/object:Gem::Version
|
92
|
-
version: 2022.1.
|
92
|
+
version: 2022.1.27
|
93
93
|
type: :runtime
|
94
94
|
prerelease: false
|
95
95
|
version_requirements: !ruby/object:Gem::Requirement
|
96
96
|
requirements:
|
97
97
|
- - "~>"
|
98
98
|
- !ruby/object:Gem::Version
|
99
|
-
version: 2022.1.
|
99
|
+
version: 2022.1.27
|
100
100
|
- - ">="
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: 2022.1.
|
102
|
+
version: 2022.1.27
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: hx_cbor
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|