VictoriaFreSh 2020.7.43 → 2020.8.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/victoriafresh.rb +50 -25
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f11c77fa1613f7abb1115e42cc3803c042efc756346c0053d17a8aa33a1a3589
|
4
|
+
data.tar.gz: e45655df3304cee4c976cb663734cb9fd75a373369c16ceb06fb0eb78edbd334
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1227d165836ad8b3c3d19fd1eb91f886d3cd7401cc087d5c0e4fd6c22208573f79bbd222422496465524975455315aebea5648b8aed6b7a9c0bf188d08abd4d1
|
7
|
+
data.tar.gz: c7aa3118a9204ca443e70c4b67552c8bdd17f998f5ee45188b097f2a1da40998e61945d7cc09f96e019acd43b2861b8e840d3dce266f551539e45d2ae3ded669
|
data/lib/victoriafresh.rb
CHANGED
@@ -35,10 +35,22 @@ class VictoriaFresh
|
|
35
35
|
|
36
36
|
end #writeFile(pathPrefix, packagedFile, contentString) #写入文件
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
#创建符号链接
|
39
|
+
def makeSymlink(pathPrefix, packagedFile, contentString)
|
40
|
+
victoriaFreshData=contentString[ packagedFile['file_start_index'], packagedFile['file_length'] ] #获取内容
|
41
|
+
|
42
|
+
pathToMake=pathPrefix + '/' + packagedFile['name'] #构造文件名
|
41
43
|
|
44
|
+
# victoriaFreshDataFile=File.new(pathToMake , "wb") #数据文件。
|
45
|
+
# victoriaFreshDataFile.syswrite(victoriaFreshData) #写入文件。
|
46
|
+
# victoriaFreshDataFile.close #关闭文件。
|
47
|
+
#
|
48
|
+
# FileUtils.touch pathToMake, :mtime => timeObject #设置修改时间
|
49
|
+
|
50
|
+
FileUtils.symlink(victoriaFreshData, pathToMake, force: true) #创建符号链接
|
51
|
+
end #def makeSymlink(pathPrefix, packagedFile, contentString) #创建符号链接
|
52
|
+
|
53
|
+
def getTimeObject(packagedFile) #构造时间戳对象
|
42
54
|
# seconds=packagedFile.timestamp.seconds #获取秒数
|
43
55
|
seconds=packagedFile['timestamp']['seconds'] #获取秒数
|
44
56
|
|
@@ -80,6 +92,9 @@ class VictoriaFresh
|
|
80
92
|
# if packagedFile.is_file #是文件,则直接写入文件
|
81
93
|
if packagedFile['is_file'] #是文件,则直接写入文件
|
82
94
|
writeFile(pathPrefix, packagedFile, contentString) #写入文件
|
95
|
+
elsif packagedFile['is_symlink'] #是符号链接,则创建符号链接
|
96
|
+
makeSymlink(pathPrefix, packagedFile, contentString) #创建符号链接
|
97
|
+
# writeFile(pathPrefix, packagedFile, contentString) #写入文件
|
83
98
|
else #是目录,则创建目录,并递归处理
|
84
99
|
makeDirectory(pathPrefix, packagedFile) #创建目录
|
85
100
|
|
@@ -111,43 +126,54 @@ class VictoriaFresh
|
|
111
126
|
|
112
127
|
baseName=directoryPathName.basename.to_s #基本文件名。
|
113
128
|
|
114
|
-
# packagedFile.name=baseName #设置文件名。
|
115
129
|
packagedFile['name']=baseName #设置文件名。
|
116
130
|
|
117
131
|
isFile=directoryPathName.file? #是否是文件。
|
132
|
+
isSymLink=directoryPathName.symlink? #是否是符号链接
|
118
133
|
|
119
|
-
# packagedFile.is_file=isFile #设置属性,是否是文件。
|
120
134
|
packagedFile['is_file']=isFile #设置属性,是否是文件。
|
121
|
-
|
122
|
-
# packagedFile.file_start_index=startIndex #记录文件内容的开始位置。
|
123
135
|
packagedFile['file_start_index']=startIndex #记录文件内容的开始位置。
|
124
136
|
|
125
|
-
|
126
|
-
|
127
|
-
mtimeStamp=File.mtime(directoryPath) #获取时间戳
|
137
|
+
packagedFile['is_symlink']=isSymLink #设置属性,是否是符号链接
|
138
|
+
|
128
139
|
puts directoryPath #Dbug.
|
129
|
-
puts mtimeStamp #Debug
|
130
|
-
puts mtimeStamp.tv_sec #Debug
|
131
|
-
puts mtimeStamp.tv_nsec #Debug
|
132
140
|
|
133
|
-
|
134
|
-
|
141
|
+
#记录时间戳:
|
142
|
+
begin #读取时间戳
|
143
|
+
mtimeStamp=File.mtime(directoryPath) #获取时间戳
|
144
|
+
# puts mtimeStamp #Debug
|
135
145
|
|
136
|
-
|
137
|
-
|
146
|
+
packagedFile['timestamp']={} #时间戳
|
147
|
+
packagedFile['timestamp']['seconds']=mtimeStamp.tv_sec #设置秒数
|
148
|
+
packagedFile['timestamp']['nanos']=mtimeStamp.tv_nsec #设置纳秒数
|
149
|
+
|
150
|
+
rescue Errno::ENOENT
|
138
151
|
|
152
|
+
end #begin #读取时间戳
|
139
153
|
|
140
|
-
# packagedFile.timestamp.nanos=mtimeStamp.tv_nsec #设置纳秒数
|
141
|
-
packagedFile['timestamp']['nanos']=mtimeStamp.tv_nsec #设置纳秒数
|
142
154
|
|
143
155
|
if (isFile) #是文件,不用再列出其子文件了。
|
144
|
-
# packagedFile.file_length=directoryPathName.size #记录文件的内容长度。
|
145
156
|
packagedFile['file_length']=directoryPathName.size #记录文件的内容长度。
|
146
157
|
|
147
158
|
#读取文件内容:
|
148
159
|
fileToReadContent=File.new(directoryPath,"rb") #创建文件。
|
149
160
|
contentString=fileToReadContent.read #全部读取。
|
150
161
|
|
162
|
+
# puts("encoding: #{contentString.encoding}") #Debug.
|
163
|
+
elsif (isSymLink) #是符号链接
|
164
|
+
# puts("sub file: #{directoryPathName}, class: #{directoryPathName.class}, symlink: #{directoryPathName.symlink?}, expand_path: #{directoryPathName.expand_path}, file?: #{directoryPathName.file?}, read link: #{directoryPathName.readlink}") #Debug.
|
165
|
+
|
166
|
+
linkTarget=directoryPathName.readlink #获取链接目标
|
167
|
+
|
168
|
+
# 待续,设置内容长度。符号链接字符串的长度
|
169
|
+
packagedFile['file_length']=linkTarget.to_s.bytesize #记录文件的内容长度。
|
170
|
+
|
171
|
+
#读取文件内容:
|
172
|
+
# fileToReadContent=File.new(directoryPath,"rb") #创建文件。
|
173
|
+
contentString=StringIO.new(linkTarget.to_s).binmode.read #全部读取。
|
174
|
+
# contentString=linkTarget.to_s.encode('UTF-8') #全部读取。
|
175
|
+
puts("encoding: #{contentString.encoding}") #Debug.
|
176
|
+
puts("content string: #{contentString}") #Debug
|
151
177
|
else #是目录。
|
152
178
|
contentString="" #容纳内容的字符串。
|
153
179
|
subFileStartIndex=startIndex #子文件的起始位置,以此目录的起始位置为基准。
|
@@ -156,20 +182,19 @@ class VictoriaFresh
|
|
156
182
|
packagedFile['file_length']=0 #本目录的内容长度。
|
157
183
|
|
158
184
|
directoryPathName.each_child do |subFile| #一个个文件地处理。
|
159
|
-
|
160
|
-
|
185
|
+
# puts("sub file: #{subFile}, class: #{subFile.class}, symlink: #{subFile.symlink?}, expand_path: #{subFile.expand_path}, file?: #{subFile.file?}") #Debug.
|
186
|
+
realPath=subFile.expand_path #获取绝对路径。
|
161
187
|
|
162
188
|
packagedSubFile,subFileContent=checkOnce(realPath,subFileStartIndex) #打包这个子文件。
|
163
189
|
|
164
|
-
# packagedFile.sub_files << packagedSubFile #加入到子文件列表中。
|
165
190
|
packagedFile['sub_files'] << packagedSubFile #加入到子文件列表中。
|
166
191
|
|
192
|
+
# puts("sub file content: #{subFileContent}") #Debug
|
193
|
+
|
167
194
|
contentString = contentString + subFileContent #串接文件内容。
|
168
195
|
|
169
|
-
# subFileStartIndex+=packagedSubFile.file_length #记录打包的子文件的长度,更新下一个要打包的子文件的起始位置。
|
170
196
|
subFileStartIndex+=packagedSubFile['file_length'] #记录打包的子文件的长度,更新下一个要打包的子文件的起始位置。
|
171
197
|
|
172
|
-
# packagedFile.file_length+=packagedSubFile.file_length #随着子文件的打包而更新本目录的总长度。
|
173
198
|
packagedFile['file_length']+=packagedSubFile['file_length'] #随着子文件的打包而更新本目录的总长度。
|
174
199
|
end #directoryPathName.each_child do |subFile| #一个个文件地处理。
|
175
200
|
end #if (isFile) #是文件,不用再列出其子文件了。
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: VictoriaFreSh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2020.
|
4
|
+
version: 2020.8.24
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hxcan Cai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-08-
|
11
|
+
date: 2020-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cbor
|