YkLib 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +6 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +34 -0
- data/LICENSE.txt +21 -0
- data/README.md +44 -0
- data/Rakefile +6 -0
- data/YkLib.gemspec +29 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/YkLib/Yk/__advance__.rb +151 -0
- data/lib/YkLib/Yk/__defun__.rb +44 -0
- data/lib/YkLib/Yk/__hook__.rb +244 -0
- data/lib/YkLib/Yk/__minmax__.rb +123 -0
- data/lib/YkLib/Yk/__stdlog.rb +329 -0
- data/lib/YkLib/Yk/adhocLiterals/email.rb +119 -0
- data/lib/YkLib/Yk/adhocLiterals/path.rb +402 -0
- data/lib/YkLib/Yk/adhocLiterals/tag.rb +19 -0
- data/lib/YkLib/Yk/adhocLiterals/url.rb +36 -0
- data/lib/YkLib/Yk/adhocLiterals.rb +199 -0
- data/lib/YkLib/Yk/auto_escseq.rb +5 -0
- data/lib/YkLib/Yk/auto_pstore.rb +179 -0
- data/lib/YkLib/Yk/bsearch.rb +120 -0
- data/lib/YkLib/Yk/clambda.rb +309 -0
- data/lib/YkLib/Yk/confLine.rb +423 -0
- data/lib/YkLib/Yk/create_tty_width_available.rb +24 -0
- data/lib/YkLib/Yk/crypt.rb +26 -0
- data/lib/YkLib/Yk/debug2 +1 -0
- data/lib/YkLib/Yk/debug2.rb +473 -0
- data/lib/YkLib/Yk/debugout.rb +139 -0
- data/lib/YkLib/Yk/email_tz.rb +533 -0
- data/lib/YkLib/Yk/enum_expect.rb +170 -0
- data/lib/YkLib/Yk/errlog.rb +5 -0
- data/lib/YkLib/Yk/escseq.rb +59 -0
- data/lib/YkLib/Yk/eval_alt.rb +281 -0
- data/lib/YkLib/Yk/expector.rb +93 -0
- data/lib/YkLib/Yk/fetch.rb +556 -0
- data/lib/YkLib/Yk/fetch_old.rb +290 -0
- data/lib/YkLib/Yk/fib.rb +158 -0
- data/lib/YkLib/Yk/file_aux.rb +843 -0
- data/lib/YkLib/Yk/file_aux2.rb +919 -0
- data/lib/YkLib/Yk/file_aux_old.rb +160 -0
- data/lib/YkLib/Yk/filemod.rb +19 -0
- data/lib/YkLib/Yk/force_escseq.rb +3 -0
- data/lib/YkLib/Yk/generator__.rb +144 -0
- data/lib/YkLib/Yk/generator__.rb.org +139 -0
- data/lib/YkLib/Yk/indenter/argless_case.rb +46 -0
- data/lib/YkLib/Yk/indenter/each_token.rb +671 -0
- data/lib/YkLib/Yk/indenter/free_case.rb +313 -0
- data/lib/YkLib/Yk/indenter/if_less.rb +53 -0
- data/lib/YkLib/Yk/indenter/independent_ensure.rb +23 -0
- data/lib/YkLib/Yk/indenter/independent_rescue.rb +23 -0
- data/lib/YkLib/Yk/indenter/operand_circumflex.rb +0 -0
- data/lib/YkLib/Yk/indenter/operand_period.rb +16 -0
- data/lib/YkLib/Yk/indenter/parenless_and.rb +37 -0
- data/lib/YkLib/Yk/indenter/post_test.rb +48 -0
- data/lib/YkLib/Yk/indenter/token.rb +1525 -0
- data/lib/YkLib/Yk/indenter.rb +1382 -0
- data/lib/YkLib/Yk/inot.rb +265 -0
- data/lib/YkLib/Yk/intf.rb +815 -0
- data/lib/YkLib/Yk/io_aux.rb +1332 -0
- data/lib/YkLib/Yk/ioctl.rb +60 -0
- data/lib/YkLib/Yk/ipcc.rb +87 -0
- data/lib/YkLib/Yk/ipcountry.rb +207 -0
- data/lib/YkLib/Yk/ipv4adr.rb +318 -0
- data/lib/YkLib/Yk/localmail.rb +276 -0
- data/lib/YkLib/Yk/method_chain.rb +359 -0
- data/lib/YkLib/Yk/misc_tz.rb +1716 -0
- data/lib/YkLib/Yk/missing_method.rb +50 -0
- data/lib/YkLib/Yk/mojiConv.rb +257 -0
- data/lib/YkLib/Yk/nostdlog.rb +4 -0
- data/lib/YkLib/Yk/on_marshal.rb +20 -0
- data/lib/YkLib/Yk/overrider.rb +47 -0
- data/lib/YkLib/Yk/path.rb +293 -0
- data/lib/YkLib/Yk/path_aux.rb +883 -0
- data/lib/YkLib/Yk/path_aux_alt.rb +0 -0
- data/lib/YkLib/Yk/path_rep.rb +1267 -0
- data/lib/YkLib/Yk/pg_setup.rb +917 -0
- data/lib/YkLib/Yk/procinfo.rb +314 -0
- data/lib/YkLib/Yk/proclist.rb +492 -0
- data/lib/YkLib/Yk/property.rb +863 -0
- data/lib/YkLib/Yk/ranger.rb +606 -0
- data/lib/YkLib/Yk/resolv_tz.rb +88 -0
- data/lib/YkLib/Yk/rlprompt.rb +73 -0
- data/lib/YkLib/Yk/rootexec.rb +48 -0
- data/lib/YkLib/Yk/rpm-packageproxy.rb +784 -0
- data/lib/YkLib/Yk/rpm-packageproxy2.rb +1430 -0
- data/lib/YkLib/Yk/rwhen.rb +21 -0
- data/lib/YkLib/Yk/selector.rb +124 -0
- data/lib/YkLib/Yk/set.rb +170 -0
- data/lib/YkLib/Yk/shellquote.rb +300 -0
- data/lib/YkLib/Yk/sio.rb +1001 -0
- data/lib/YkLib/Yk/sio0.rb +835 -0
- data/lib/YkLib/Yk/sio_aux.rb +1524 -0
- data/lib/YkLib/Yk/sio_inot.rb +86 -0
- data/lib/YkLib/Yk/sock_aux.rb +42 -0
- data/lib/YkLib/Yk/spipe.rb +843 -0
- data/lib/YkLib/Yk/sql_table.rb +565 -0
- data/lib/YkLib/Yk/stdlog.rb +4 -0
- data/lib/YkLib/Yk/syscommand.rb +173 -0
- data/lib/YkLib/Yk/sysinit.rb +75 -0
- data/lib/YkLib/Yk/ttyFontWidth.rb +46113 -0
- data/lib/YkLib/Yk/tty_char.dump +0 -0
- data/lib/YkLib/Yk/tty_char.rb +47 -0
- data/lib/YkLib/Yk/tty_char_create.rb +437031 -0
- data/lib/YkLib/Yk/tty_char_static.rb +437016 -0
- data/lib/YkLib/Yk/tty_rewrite.rb +142 -0
- data/lib/YkLib/Yk/tty_str.rb +461 -0
- data/lib/YkLib/Yk/tty_width.dat.rb +114 -0
- data/lib/YkLib/Yk/tty_width.rb +180 -0
- data/lib/YkLib/Yk/tty_width_available +569 -0
- data/lib/YkLib/Yk/tty_width_list +0 -0
- data/lib/YkLib/Yk/tty_width_list.linux +280 -0
- data/lib/YkLib/Yk/tty_width_list.windows +324 -0
- data/lib/YkLib/Yk/tz_tty +0 -0
- data/lib/YkLib/Yk/tz_tty.rb +0 -0
- data/lib/YkLib/Yk/uprepos.rb +94 -0
- data/lib/YkLib/Yk/userinfo.rb +91 -0
- data/lib/YkLib/Yk/with.rb +109 -0
- data/lib/YkLib/version.rb +3 -0
- data/lib/YkLib.rb +6 -0
- metadata +170 -0
@@ -0,0 +1,1267 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
require 'Yk/file_aux'
|
4
|
+
require 'Yk/__hook__'
|
5
|
+
|
6
|
+
def __process_ary (*args)
|
7
|
+
ret = []
|
8
|
+
args.each do |e|
|
9
|
+
if e.is_a? Array
|
10
|
+
tmpArr = []
|
11
|
+
e.each do |f|
|
12
|
+
tmpArr.push yield(f)
|
13
|
+
end
|
14
|
+
ret.push tmpArr
|
15
|
+
else
|
16
|
+
ret.push yield(e)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
if ret.size == 1
|
20
|
+
return ret[0]
|
21
|
+
elsif ret.size == 0
|
22
|
+
return nil
|
23
|
+
else
|
24
|
+
return ret
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
class PathReplicator
|
30
|
+
attr :root
|
31
|
+
FileOrg = File.__hook_group
|
32
|
+
FileUtilsOrg = FileUtils.__hook_group
|
33
|
+
IOOrg = IO.__hook_group
|
34
|
+
DirOrg = Dir.__hook_group
|
35
|
+
def rep (*args)
|
36
|
+
ret = __process_ary *args do |pth|
|
37
|
+
pth = FileOrg.normalize_path(pth)
|
38
|
+
if FileOrg.is_in(pth, @root)
|
39
|
+
pth
|
40
|
+
else
|
41
|
+
symlinked = false
|
42
|
+
linkReplicate = false
|
43
|
+
arr = pth.split /\//
|
44
|
+
arr.each_index do |i|
|
45
|
+
e = arr[0 .. i].join("/")
|
46
|
+
residue = arr[(i + 1) .. -1].join("/")
|
47
|
+
if e == ""
|
48
|
+
e = "/"
|
49
|
+
else
|
50
|
+
residue = "/" + residue
|
51
|
+
end
|
52
|
+
if @debugRootFiles[e] == nil
|
53
|
+
stat = FileOrg.lstat(e) rescue nil
|
54
|
+
if stat
|
55
|
+
@debugRootFiles[e] = 0
|
56
|
+
begin
|
57
|
+
case stat.ftype
|
58
|
+
when "symlink"
|
59
|
+
if (tmp = FileOrg.readlink(e)) =~ /^\//
|
60
|
+
if FileOrg.symlink?(tmp) || FileOrg.exist?(tmp)
|
61
|
+
rep(tmp + residue)
|
62
|
+
end
|
63
|
+
FileOrg.resymlink(@root + tmp, @root + e)
|
64
|
+
else
|
65
|
+
tmp = FileOrg.resolv_link(e)
|
66
|
+
if FileOrg.symlink?(tmp) || FileOrg.exist?(tmp)
|
67
|
+
rep(tmp + residue)
|
68
|
+
end
|
69
|
+
FileOrg.resymlink(tmp, @root + e)
|
70
|
+
end
|
71
|
+
FileUtilsOrg.cp_stat(e, @root + e)
|
72
|
+
symlinked = true
|
73
|
+
when "directory"
|
74
|
+
FileUtilsOrg.mkdir_p(@root + e)
|
75
|
+
FileUtilsOrg.cp_stat(e, @root + e)
|
76
|
+
else
|
77
|
+
FileUtilsOrg.copy_entry(e, @root + e)
|
78
|
+
end
|
79
|
+
rescue => e
|
80
|
+
STDERR.write "#{e.class}:#{e}\n"
|
81
|
+
end
|
82
|
+
else
|
83
|
+
@debugRootFiles[e] = -1
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
@root + pth
|
88
|
+
end
|
89
|
+
end
|
90
|
+
ret
|
91
|
+
end
|
92
|
+
def setModified (f)
|
93
|
+
if @debugRootFiles[f] != -1 && @debugRootFiles[f] != nil
|
94
|
+
@debugRootFiles[f] = 1
|
95
|
+
end
|
96
|
+
end
|
97
|
+
def check
|
98
|
+
@debugRootFiles.each_key do |e|
|
99
|
+
if !FileOrg.symlink?(@root + e) && !FileOrg.exist?(@root + e)
|
100
|
+
@debugRootFiles[e] = -1
|
101
|
+
elsif @debugRootFiles[e] == -1
|
102
|
+
@debugRootFiles[e] = 1
|
103
|
+
end
|
104
|
+
end
|
105
|
+
recCheck = Proc.new do |pth|
|
106
|
+
pth =~ /^#{Regexp.escape @root}(\/|$)/
|
107
|
+
r = "/" + $'
|
108
|
+
if @debugRootFiles[r] == nil
|
109
|
+
@debugRootFiles[r] = 1
|
110
|
+
end
|
111
|
+
if !FileOrg.symlink?(pth) && FileOrg.directory?(pth)
|
112
|
+
DirOrg.foreach pth do |f|
|
113
|
+
if f != "." && f != ".."
|
114
|
+
recCheck.call pth + "/" + f
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
recCheck.call @root
|
120
|
+
end
|
121
|
+
def conv (*args)
|
122
|
+
__process_ary *args do |pth|
|
123
|
+
pth = FileOrg.normalize_path(pth)
|
124
|
+
if FileOrg.is_in(pth, @root)
|
125
|
+
pth
|
126
|
+
else
|
127
|
+
arr = pth.split /\//
|
128
|
+
mustConv = false
|
129
|
+
arr.each_index do |i|
|
130
|
+
sp = arr[0..i].join("/")
|
131
|
+
sp == "" && sp = "/"
|
132
|
+
if @debugRootFiles[sp] == -1 || (@debugRootFiles[sp] != nil && i == arr.size - 1 && @debugRootFiles[sp] >= 0)
|
133
|
+
mustConv = true
|
134
|
+
end
|
135
|
+
end
|
136
|
+
if !mustConv
|
137
|
+
pth
|
138
|
+
else
|
139
|
+
if pth == "/"
|
140
|
+
root
|
141
|
+
else
|
142
|
+
root + "/" + pth
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
def rev (*args)
|
149
|
+
__process_ary *args do |pth|
|
150
|
+
if pth == @root
|
151
|
+
"/"
|
152
|
+
else
|
153
|
+
if pth !~ /^#{Regexp.escape(@root)}(\/|$)/
|
154
|
+
pth
|
155
|
+
else
|
156
|
+
"/" + $'
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
def deleted? (pth)
|
162
|
+
pth = FileOrg.normalize_path(pth)
|
163
|
+
@debugRootFiles[pth] == -1
|
164
|
+
end
|
165
|
+
def altered? (pth)
|
166
|
+
pth = FileOrg.normalize_path(pth)
|
167
|
+
@debugRootFiles[pth] == 1
|
168
|
+
end
|
169
|
+
def initialize (r)
|
170
|
+
@root = r
|
171
|
+
@debugRootFiles = Hash.new
|
172
|
+
if FileOrg.normalize_path(r) == "/"
|
173
|
+
raise ArgumentError.new("cannot replicate to '/'")
|
174
|
+
end
|
175
|
+
end
|
176
|
+
def setDefault (obj)
|
177
|
+
@@default = obj
|
178
|
+
end
|
179
|
+
def normalizeReplicated
|
180
|
+
normList = Hash.new
|
181
|
+
@debugRootFiles.each do |k, v|
|
182
|
+
if v == 1
|
183
|
+
arr = k.split(/\//)
|
184
|
+
arr.each_index do |i|
|
185
|
+
tmp = arr[0..i].join("/")
|
186
|
+
if tmp == ""
|
187
|
+
tmp = "/"
|
188
|
+
end
|
189
|
+
normList[tmp] = true
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
@debugRootFiles.each_key do |k|
|
194
|
+
if !normList[k]
|
195
|
+
FileUtilsOrg.rm_f @root + k
|
196
|
+
elsif FileOrg.symlink? @root + k
|
197
|
+
lnk = FileOrg.readlink @root + k
|
198
|
+
if lnk =~ /^#{Regexp.escape @root}(\/|$)/
|
199
|
+
lnk = "/" + $'
|
200
|
+
FileUtilsOrg.ln_sf @root + k, lnk
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
def PathReplicator.default
|
206
|
+
@@default
|
207
|
+
end
|
208
|
+
@@default = nil
|
209
|
+
def PathReplicator.[] (*args)
|
210
|
+
if @@default
|
211
|
+
@@default.conv(*args)
|
212
|
+
else
|
213
|
+
if args.size <= 1
|
214
|
+
args[0]
|
215
|
+
else
|
216
|
+
args
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
def PathReplicator.conv (*args)
|
221
|
+
if @@default
|
222
|
+
@@default.conv(*args)
|
223
|
+
else
|
224
|
+
if args.size <= 1
|
225
|
+
args[0]
|
226
|
+
else
|
227
|
+
args
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
231
|
+
def PathReplicator.rep (*args)
|
232
|
+
if @@default
|
233
|
+
begin
|
234
|
+
ret = cv = @@default.rep(args)
|
235
|
+
if ret.size <= 1
|
236
|
+
ret = ret[0]
|
237
|
+
end
|
238
|
+
if block_given?
|
239
|
+
ret = yield *cv
|
240
|
+
end
|
241
|
+
ensure
|
242
|
+
@@default.check
|
243
|
+
end
|
244
|
+
ret
|
245
|
+
else
|
246
|
+
if args.size <= 1
|
247
|
+
ret = args[0]
|
248
|
+
else
|
249
|
+
ret = args
|
250
|
+
end
|
251
|
+
if block_given?
|
252
|
+
ret = yield *args
|
253
|
+
end
|
254
|
+
ret
|
255
|
+
end
|
256
|
+
end
|
257
|
+
def PathReplicator.rev (*args)
|
258
|
+
if @@default
|
259
|
+
@@default.rev(*args)
|
260
|
+
else
|
261
|
+
if args.size <= 1
|
262
|
+
args[0]
|
263
|
+
else
|
264
|
+
args
|
265
|
+
end
|
266
|
+
end
|
267
|
+
end
|
268
|
+
def PathReplicator.deleted? (arg)
|
269
|
+
if @@default
|
270
|
+
@@default.deleted? arg
|
271
|
+
else
|
272
|
+
false
|
273
|
+
end
|
274
|
+
end
|
275
|
+
def PathReplicator.root
|
276
|
+
if @@default
|
277
|
+
@@default.root
|
278
|
+
else
|
279
|
+
nil
|
280
|
+
end
|
281
|
+
end
|
282
|
+
def PathReplicator.setRoot (r)
|
283
|
+
r = File.resolv_link(r)
|
284
|
+
@@default = PathReplicator.new(r)
|
285
|
+
@@default.check
|
286
|
+
end
|
287
|
+
def PathReplicator.setModified (f)
|
288
|
+
if @@default
|
289
|
+
if f.is_a? Array
|
290
|
+
f.each do |e|
|
291
|
+
@@default.setModified(e)
|
292
|
+
end
|
293
|
+
else
|
294
|
+
@@default.setModified(f)
|
295
|
+
end
|
296
|
+
end
|
297
|
+
end
|
298
|
+
def PathReplicator.normalizeReplicated
|
299
|
+
if @@default
|
300
|
+
@@default.normalizeReplicated
|
301
|
+
end
|
302
|
+
end
|
303
|
+
def PathReplicator.check
|
304
|
+
if @@default
|
305
|
+
@@default.check
|
306
|
+
end
|
307
|
+
end
|
308
|
+
def PathReplicator.set?
|
309
|
+
@@default != nil
|
310
|
+
end
|
311
|
+
end
|
312
|
+
|
313
|
+
|
314
|
+
if ENV['DEBUG'] || defined? DEBUG
|
315
|
+
if !defined? DEBUG_ROOT
|
316
|
+
DEBUG_ROOT = "/var/tmp/debug_rep/#{File.dirname($0)}/#{$$}/root"
|
317
|
+
FileUtils.mkdir_p DEBUG_ROOT
|
318
|
+
end
|
319
|
+
PathReplicator.setRoute(DEBUG_ROOT)
|
320
|
+
end
|
321
|
+
|
322
|
+
|
323
|
+
class << File
|
324
|
+
org = PathReplicator::FileOrg
|
325
|
+
|
326
|
+
__hook__ :lstat do |closure|
|
327
|
+
org.lstat PathReplicator[closure.args[0]]
|
328
|
+
end
|
329
|
+
|
330
|
+
__hook__ :stat do |closure|
|
331
|
+
org.stat PathReplicator[closure.args[0]]
|
332
|
+
end
|
333
|
+
|
334
|
+
__hook__ :readlink do |closure|
|
335
|
+
tmp = org.readlink PathReplicator[closure.args[0]]
|
336
|
+
if tmp !~ /^\//
|
337
|
+
tmp
|
338
|
+
else
|
339
|
+
PathReplicator.rev(closure.arg[0])
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
343
|
+
__hook__ :symlink do |closure|
|
344
|
+
begin
|
345
|
+
if args[0] !~ /^\//
|
346
|
+
d = File.dirname(closure.args[1])
|
347
|
+
if d[-1] == ?/
|
348
|
+
f = d + args[0]
|
349
|
+
else
|
350
|
+
f = d + "/" + closure.args[0]
|
351
|
+
end
|
352
|
+
PathReplicator.rep(f)
|
353
|
+
else
|
354
|
+
f = closure.args[0]
|
355
|
+
closure.args[0] = PathReplicator.rep(f)
|
356
|
+
end
|
357
|
+
closure.args[1] = PathReplicator.rep(closure.args[1])
|
358
|
+
org.symlink *closure.args
|
359
|
+
ensure
|
360
|
+
PathReplicator.check
|
361
|
+
PathReplicator.setModified(closure.args[1])
|
362
|
+
end
|
363
|
+
end
|
364
|
+
|
365
|
+
__hook__ :exist? do |closure|
|
366
|
+
c = PathReplicator.conv(closure.args[0])
|
367
|
+
org.exist? c
|
368
|
+
end
|
369
|
+
|
370
|
+
__hook__ :symlink? do |closure|
|
371
|
+
org.symlink? PathReplicator.conv(closure.args[0])
|
372
|
+
end
|
373
|
+
|
374
|
+
__hook__ :chmod do |closure|
|
375
|
+
files = closure.args[1..-1]
|
376
|
+
mode = closure.args[0]
|
377
|
+
PathReplicator.rep(files) do |fls|
|
378
|
+
org.chmod mode, *fls
|
379
|
+
end
|
380
|
+
PathReplicator.setModified(files)
|
381
|
+
end
|
382
|
+
|
383
|
+
__hook__ :lchmod do |closure|
|
384
|
+
files = closure.args[1..-1]
|
385
|
+
mode = closure.args[0]
|
386
|
+
PathReplicator.rep(files) do |fls|
|
387
|
+
org.lchmod mode, *fls
|
388
|
+
end
|
389
|
+
PathReplicator.setModified(files)
|
390
|
+
end
|
391
|
+
|
392
|
+
__hook__ :chown do |closure|
|
393
|
+
o = closure.args[0]
|
394
|
+
g = closure.args[1]
|
395
|
+
files = closure.args[2..-1]
|
396
|
+
PathReplicator.rep(files) do |fls|
|
397
|
+
org.chown o, g, *fls
|
398
|
+
end
|
399
|
+
PathReplicator.setModified(files)
|
400
|
+
end
|
401
|
+
|
402
|
+
__hook__ :lchown do |closure|
|
403
|
+
o = closure.args[0]
|
404
|
+
g = closure.args[1]
|
405
|
+
files = closure.args[2..-1]
|
406
|
+
PathReplicator.rep(files) do |fls|
|
407
|
+
org.lchown o, g, *fls
|
408
|
+
end
|
409
|
+
PathReplicator.setModified(files)
|
410
|
+
end
|
411
|
+
|
412
|
+
__hook__ :delete do |closure|
|
413
|
+
files = closure.args
|
414
|
+
PathReplicator.rep(files) do |fls|
|
415
|
+
org.delete *fls
|
416
|
+
end
|
417
|
+
end
|
418
|
+
|
419
|
+
__hook__ :unlink do |closure|
|
420
|
+
files = closure.args
|
421
|
+
PathReplicator.rep(files) do |fls|
|
422
|
+
org.unlink *fls
|
423
|
+
end
|
424
|
+
end
|
425
|
+
|
426
|
+
__hook__ :new do |closure|
|
427
|
+
path = closure.args[0]
|
428
|
+
args = closure.args[1..-1]
|
429
|
+
bl = closure.block
|
430
|
+
org.open(path, *args, &bl)
|
431
|
+
end
|
432
|
+
|
433
|
+
__hook__ :open do |closure|
|
434
|
+
path = closure.args[0]
|
435
|
+
args = closure.args[1..-1]
|
436
|
+
bl = closure.block
|
437
|
+
if path[0] != ?|
|
438
|
+
if args.size == 0 || args[0] !~ /[w\+]/ #read
|
439
|
+
org.open PathReplicator[args[0]], *args, &bl
|
440
|
+
else #write
|
441
|
+
PathReplicator.rep path do |a|
|
442
|
+
org.open a, *args, &bl
|
443
|
+
end
|
444
|
+
PathReplicator.setModified(path)
|
445
|
+
end
|
446
|
+
else
|
447
|
+
org.open path, *args, &bl
|
448
|
+
end
|
449
|
+
end
|
450
|
+
|
451
|
+
__hook__ :rename do |closure|
|
452
|
+
PathReplicator.rep closure.args do |fls|
|
453
|
+
org.rename *fls
|
454
|
+
end
|
455
|
+
PathReplicator.setModified(closure.args[1])
|
456
|
+
end
|
457
|
+
|
458
|
+
__hook__ :truncate do |closure|
|
459
|
+
file, len = closure.args
|
460
|
+
PathReplicator.rep file do |f|
|
461
|
+
org.truncate f, len
|
462
|
+
end
|
463
|
+
PathReplicator.setModified(file)
|
464
|
+
end
|
465
|
+
|
466
|
+
__hook__ :utime do |closure|
|
467
|
+
atime, mtime, *files = closure.args
|
468
|
+
PathReplicator.rep files do |fls|
|
469
|
+
org.utime atime, mtime, *fls
|
470
|
+
end
|
471
|
+
PathReplicator.setModified(files)
|
472
|
+
end
|
473
|
+
|
474
|
+
__hook__ :atime do |closure|
|
475
|
+
filename = closure.args[0]
|
476
|
+
org.atime PathReplicator[filename]
|
477
|
+
end
|
478
|
+
|
479
|
+
__hook__ :ctime do |closure|
|
480
|
+
filename = closure.args[0]
|
481
|
+
org.ctime PathReplicator[filename]
|
482
|
+
end
|
483
|
+
|
484
|
+
__hook__ :mtime do |closure|
|
485
|
+
filename = closure.args[0]
|
486
|
+
org.mtime PathReplicator[filename]
|
487
|
+
end
|
488
|
+
|
489
|
+
__hook__ :expand_path do |closure|
|
490
|
+
args = closure.args
|
491
|
+
path, defalutDir = args[0], args[1]
|
492
|
+
defaultDir = Dir.pwd
|
493
|
+
org.expand_path path, defaultDir
|
494
|
+
end
|
495
|
+
|
496
|
+
__hook__ :ftype do |closure|
|
497
|
+
filename = closure.args[0]
|
498
|
+
org.ftype PathReplicator[filename]
|
499
|
+
end
|
500
|
+
|
501
|
+
__hook__ :blockdev? do |closure|
|
502
|
+
path = closure.args[0]
|
503
|
+
org.blockdev? PathReplicator[path]
|
504
|
+
end
|
505
|
+
|
506
|
+
__hook__ :chardev? do |closure|
|
507
|
+
path = closure.args[0]
|
508
|
+
org.chardev? PathReplicator[path]
|
509
|
+
end
|
510
|
+
|
511
|
+
__hook__ :directory? do |closure|
|
512
|
+
path = closure.args[0]
|
513
|
+
org.directory? PathReplicator[path]
|
514
|
+
end
|
515
|
+
|
516
|
+
__hook__ :executable? do |closure|
|
517
|
+
path = closure.args[0]
|
518
|
+
org.executable? PathReplicator[path]
|
519
|
+
end
|
520
|
+
|
521
|
+
__hook__ :executable_real? do |closure|
|
522
|
+
path = closure.args[0]
|
523
|
+
org.executable_real? PathReplicator[path]
|
524
|
+
end
|
525
|
+
|
526
|
+
__hook__ :exist? do |closure|
|
527
|
+
path = closure.args[0]
|
528
|
+
org.exist? PathReplicator[path]
|
529
|
+
end
|
530
|
+
|
531
|
+
__hook__ :file? do |closure|
|
532
|
+
path = closure.args[0]
|
533
|
+
org.file? PathReplicator[path]
|
534
|
+
end
|
535
|
+
|
536
|
+
__hook__ :grpowned? do |closure|
|
537
|
+
path = closure.args[0]
|
538
|
+
org.grpowned? PathReplicator[path]
|
539
|
+
end
|
540
|
+
|
541
|
+
__hook__ :owned? do |closure|
|
542
|
+
path = closure.args[0]
|
543
|
+
org.owned? PathReplicator[path]
|
544
|
+
end
|
545
|
+
|
546
|
+
__hook__ :identical? do |closure|
|
547
|
+
path1 = closure.args[0]
|
548
|
+
path2 = closure.args[1]
|
549
|
+
org.identical? PathReplicator[path]
|
550
|
+
end
|
551
|
+
|
552
|
+
__hook__ :pipe? do |closure|
|
553
|
+
path = closure.args[0]
|
554
|
+
org.pipe? PathReplicator[path]
|
555
|
+
end
|
556
|
+
|
557
|
+
__hook__ :readable? do |closure|
|
558
|
+
path = closure.args[0]
|
559
|
+
org.readable? PathReplicator[path]
|
560
|
+
end
|
561
|
+
|
562
|
+
__hook__ :readable_real? do |closure|
|
563
|
+
path = closure.args[0]
|
564
|
+
org.readable_real? PathReplicator[path]
|
565
|
+
end
|
566
|
+
|
567
|
+
__hook__ :setgid? do |closure|
|
568
|
+
path = closure.args[0]
|
569
|
+
org.setgid? PathReplicator[path]
|
570
|
+
end
|
571
|
+
|
572
|
+
__hook__ :setuid? do |closure|
|
573
|
+
path = closure.args[0]
|
574
|
+
org.setuid? PathReplicator[path]
|
575
|
+
end
|
576
|
+
|
577
|
+
__hook__ :size do |closure|
|
578
|
+
path = closure.args[0]
|
579
|
+
org.size PathReplicator[path]
|
580
|
+
end
|
581
|
+
|
582
|
+
__hook__ :size? do |closure|
|
583
|
+
path = closure.args[0]
|
584
|
+
org.size? PathReplicator[path]
|
585
|
+
end
|
586
|
+
|
587
|
+
__hook__ :socket? do |closure|
|
588
|
+
path = closure.args[0]
|
589
|
+
org.socket? PathReplicator[path]
|
590
|
+
end
|
591
|
+
|
592
|
+
__hook__ :sticky? do |closure|
|
593
|
+
path = closure.args[0]
|
594
|
+
org.sticky? PathReplicator[path]
|
595
|
+
end
|
596
|
+
|
597
|
+
__hook__ :writable? do |closure|
|
598
|
+
path = closure.args[0]
|
599
|
+
org.writable? PathReplicator[path]
|
600
|
+
end
|
601
|
+
|
602
|
+
__hook__ :writable_real? do |closure|
|
603
|
+
path = closure.args[0]
|
604
|
+
org.writable_real? PathReplicator[path]
|
605
|
+
end
|
606
|
+
|
607
|
+
__hook__ :zero? do |closure|
|
608
|
+
path = closure.args[0]
|
609
|
+
org.zero? PathReplicator[path]
|
610
|
+
end
|
611
|
+
|
612
|
+
end
|
613
|
+
|
614
|
+
|
615
|
+
Kernel.__hook__ :open do |closure|
|
616
|
+
File.open(*closure.args, &closure.block)
|
617
|
+
end
|
618
|
+
|
619
|
+
|
620
|
+
class << IO
|
621
|
+
org = PathReplicator::IOOrg
|
622
|
+
|
623
|
+
__hook__ :sysopen do |closure|
|
624
|
+
path, *args = closure.args
|
625
|
+
bl = closure.block
|
626
|
+
if args.size == 0 || args[0] !~ /[wx\+]/ #read
|
627
|
+
org.sysopen PathReplicator[args[0]], *args, &bl
|
628
|
+
else #write
|
629
|
+
PathReplicator.rep path do |a|
|
630
|
+
org.sysopen a, *args, &bl
|
631
|
+
end
|
632
|
+
PathReplicator.setModified(path)
|
633
|
+
end
|
634
|
+
end
|
635
|
+
|
636
|
+
__hook__ :foreach do |closure|
|
637
|
+
path, *rs = closure.args
|
638
|
+
bl = closure.block
|
639
|
+
org.foreach PathReplicator[path], *rs, &bl
|
640
|
+
end
|
641
|
+
|
642
|
+
__hook__ :read do |closure|
|
643
|
+
path, *args = closure.args
|
644
|
+
org.read PathReplicator[path], *args
|
645
|
+
end
|
646
|
+
|
647
|
+
__hook__ :readlines do |closure|
|
648
|
+
path, *args = closure.args
|
649
|
+
ret = PathReplicator[path]
|
650
|
+
org.readlines ret, *args
|
651
|
+
end
|
652
|
+
|
653
|
+
end
|
654
|
+
|
655
|
+
|
656
|
+
class << FileUtils
|
657
|
+
org = PathReplicator::FileUtilsOrg
|
658
|
+
|
659
|
+
__hook__ :ln_s do |closure|
|
660
|
+
args = closure.args
|
661
|
+
begin
|
662
|
+
if args[0] =~ /^\//
|
663
|
+
args[0] = PathReplicator.rep(args[0])
|
664
|
+
else
|
665
|
+
PathReplicator.rep(args[0])
|
666
|
+
end
|
667
|
+
args[1] = PathReplicator.rep(args[1])
|
668
|
+
org.ln_s *args
|
669
|
+
ensure
|
670
|
+
PathReplicator.check
|
671
|
+
PathReplicator.setModified(args[1])
|
672
|
+
end
|
673
|
+
end
|
674
|
+
|
675
|
+
__hook__ :ln_sf do |closure|
|
676
|
+
args = closure.args
|
677
|
+
begin
|
678
|
+
if args[0] =~ /^\//
|
679
|
+
args[0] = PathReplicator.rep(args[0])
|
680
|
+
else
|
681
|
+
PathReplicator.rep(args[0])
|
682
|
+
end
|
683
|
+
args[1] = PathReplicator.rep(args[1])
|
684
|
+
org.ln_sf *args
|
685
|
+
ensure
|
686
|
+
PathReplicator.check
|
687
|
+
PathReplicator.setModified(args[1])
|
688
|
+
end
|
689
|
+
end
|
690
|
+
|
691
|
+
__hook__ :symlink do |closure|
|
692
|
+
args = closure.args
|
693
|
+
begin
|
694
|
+
if args[0] =~ /^\//
|
695
|
+
args[0] = PathReplicator.rep(args[0])
|
696
|
+
else
|
697
|
+
PathReplicator.rep(args[0])
|
698
|
+
end
|
699
|
+
args[1] = PathReplicator.rep(args[1])
|
700
|
+
org.symlink *args
|
701
|
+
ensure
|
702
|
+
PathReplicator.check
|
703
|
+
PathReplicator.setModified(args[1])
|
704
|
+
end
|
705
|
+
end
|
706
|
+
|
707
|
+
__hook__ :copy_entry do |closure|
|
708
|
+
args = closure.args
|
709
|
+
PathReplicator.rep args[1] do |dest|
|
710
|
+
org.copy_entry PathReplicator.conv(args[0]), dest, *args[2..-1]
|
711
|
+
end
|
712
|
+
PathReplicator.setModified(args[0])
|
713
|
+
end
|
714
|
+
|
715
|
+
|
716
|
+
__hook__ :cp_stat do |closure|
|
717
|
+
args = closure.args
|
718
|
+
PathReplicator.rep args[1] do |dest|
|
719
|
+
org.cp_stat PathReplicator.conv(args[0]), dest, *args[2..-1]
|
720
|
+
end
|
721
|
+
PathReplicator.setModified(args[0])
|
722
|
+
end
|
723
|
+
|
724
|
+
|
725
|
+
__hook__ :chmod do |closure|
|
726
|
+
mode, list, options = closure.args
|
727
|
+
options = {} if closure.args.size <= 2
|
728
|
+
PathReplicator.rep list do |lst|
|
729
|
+
org.chmod mode, lst, options
|
730
|
+
end
|
731
|
+
PathReplicator.setModified(list)
|
732
|
+
end
|
733
|
+
|
734
|
+
__hook__ :chmod_R do |closure|
|
735
|
+
mode, list, options = closure.args
|
736
|
+
options = {} if closure.args.size <= 2
|
737
|
+
PathReplicator.rep list do |lst|
|
738
|
+
org.chmod_R mode, lst, options
|
739
|
+
end
|
740
|
+
PathReplicator.setModified(list)
|
741
|
+
end
|
742
|
+
|
743
|
+
__hook__ :chown do |closure|
|
744
|
+
user, group, list, options = closure.args
|
745
|
+
options = {} if closure.args.size <= 3
|
746
|
+
PathReplicator.rep list do |lst|
|
747
|
+
org.chown user, group, lst, options
|
748
|
+
end
|
749
|
+
PathReplicator.setModified(list)
|
750
|
+
end
|
751
|
+
|
752
|
+
__hook__ :chown_R do |closure|
|
753
|
+
user, group, list, options = closure.args
|
754
|
+
options = {} if closure.args.size <= 3
|
755
|
+
PathReplicator.rep list do |lst|
|
756
|
+
org.chown_R user, group, lst, options
|
757
|
+
end
|
758
|
+
PathReplicator.setModified(list)
|
759
|
+
end
|
760
|
+
|
761
|
+
__hook__ :copy_file do |closure|
|
762
|
+
args = closure.args
|
763
|
+
PathReplicator.rep args[1] do |dest|
|
764
|
+
org.copy_file PathReplicator.conv(args[0]), dest, *args[2..-1]
|
765
|
+
end
|
766
|
+
PathReplicator.setModified(args[1])
|
767
|
+
end
|
768
|
+
|
769
|
+
__hook__ :cp do |closure|
|
770
|
+
args = closure.args
|
771
|
+
PathReplicator.rep args[1] do |dest|
|
772
|
+
org.cp PathReplicator.conv(args[0]), dest, *args[2..-1]
|
773
|
+
end
|
774
|
+
PathReplicator.setModified(args[1])
|
775
|
+
end
|
776
|
+
|
777
|
+
__hook__ :copy do |closure|
|
778
|
+
args = closure.args
|
779
|
+
PathReplicator.rep args[1] do |dest|
|
780
|
+
org.copy PathReplicator.conv(args[0]), dest, *args[2..-1]
|
781
|
+
end
|
782
|
+
PathReplicator.setModified(args[1])
|
783
|
+
end
|
784
|
+
|
785
|
+
__hook__ :cp_r do |closure|
|
786
|
+
args = closure.args
|
787
|
+
PathReplicator.rep args[1] do |dest|
|
788
|
+
org.cp_r PathReplicator.conv(args[0]), dest, *args[2..-1]
|
789
|
+
end
|
790
|
+
PathReplicator.setModified(args[1])
|
791
|
+
end
|
792
|
+
|
793
|
+
__hook__ :install do |closure|
|
794
|
+
args = closure.args
|
795
|
+
PathReplicator.rep args[1] do |dest|
|
796
|
+
org.install PathReplicator.conv(args[0]), dest, *args[2..-1]
|
797
|
+
end
|
798
|
+
PathReplicator.setModified(args[1])
|
799
|
+
end
|
800
|
+
|
801
|
+
__hook__ :ln do |closure|
|
802
|
+
args = closure.args
|
803
|
+
PathReplicator.rep args[0..1] do |ags|
|
804
|
+
org.ln ags[0], ags[1], *args[2..-1]
|
805
|
+
end
|
806
|
+
PathReplicator.setModified(args[1])
|
807
|
+
end
|
808
|
+
|
809
|
+
__hook__ :link do |closure|
|
810
|
+
args = closure.args
|
811
|
+
PathReplicator.rep args[0..1] do |ags|
|
812
|
+
org.link ags[0], ags[1], *args[2..-1]
|
813
|
+
end
|
814
|
+
PathReplicator.setModified(args[1])
|
815
|
+
end
|
816
|
+
|
817
|
+
__hook__ :mkdir do |closure|
|
818
|
+
dir, options = closure.args
|
819
|
+
options = {} if closure.args.size <= 1
|
820
|
+
PathReplicator.rep dir do |d|
|
821
|
+
org.mkdir d, options
|
822
|
+
end
|
823
|
+
PathReplicator.setModified(dir)
|
824
|
+
end
|
825
|
+
|
826
|
+
__hook__ :mkdir_p do |closure|
|
827
|
+
dir, options = closure.args
|
828
|
+
options = {} if closure.args.size <= 1
|
829
|
+
PathReplicator.rep dir do |d|
|
830
|
+
org.mkdir_p d, options
|
831
|
+
end
|
832
|
+
PathReplicator.setModified(dir)
|
833
|
+
end
|
834
|
+
|
835
|
+
__hook__ :mkpath do |closure|
|
836
|
+
dir, options = closure.args
|
837
|
+
options = {} if closure.args.size <= 1
|
838
|
+
PathReplicator.rep dir do |d|
|
839
|
+
org.mkpath d, options
|
840
|
+
end
|
841
|
+
PathReplicator.setModified(dir)
|
842
|
+
end
|
843
|
+
|
844
|
+
__hook__ :makedirs do |closure|
|
845
|
+
dir, options = closure.args
|
846
|
+
options = {} if closure.args.size <= 1
|
847
|
+
PathReplicator.rep dir do |d|
|
848
|
+
org.makedirs d, options
|
849
|
+
end
|
850
|
+
PathReplicator.setModified(dir)
|
851
|
+
end
|
852
|
+
|
853
|
+
__hook__ :mv do |closure|
|
854
|
+
a, b, options = closure.args
|
855
|
+
options = {} if closure.args.size <= 2
|
856
|
+
PathReplicator.rep a, b do |_a, _b|
|
857
|
+
org.mv _a, _b, options
|
858
|
+
end
|
859
|
+
PathReplicator.setModified(b)
|
860
|
+
end
|
861
|
+
|
862
|
+
__hook__ :move do |closure|
|
863
|
+
a, b, options = closure.args
|
864
|
+
options = {} if closure.args.size <= 2
|
865
|
+
PathReplicator.rep a, b do |_a, _b|
|
866
|
+
org.move _a, _b, options
|
867
|
+
end
|
868
|
+
PathReplicator.setModified(b)
|
869
|
+
end
|
870
|
+
|
871
|
+
__hook__ :rm do |closure|
|
872
|
+
a, options = closure.args
|
873
|
+
options = {} if closure.args.size <= 1
|
874
|
+
PathReplicator.rep a do |_a|
|
875
|
+
org.rm _a, options
|
876
|
+
end
|
877
|
+
end
|
878
|
+
|
879
|
+
__hook__ :remove do |closure|
|
880
|
+
a, options = closure.args
|
881
|
+
options = {} if closure.args.size <= 1
|
882
|
+
PathReplicator.rep a do |_a|
|
883
|
+
org.remove _a, options
|
884
|
+
end
|
885
|
+
end
|
886
|
+
|
887
|
+
__hook__ :rm_f do |closure|
|
888
|
+
args = closure.args
|
889
|
+
a = args[0]
|
890
|
+
if args.size >= 2
|
891
|
+
options = args[1]
|
892
|
+
else
|
893
|
+
options = {}
|
894
|
+
end
|
895
|
+
PathReplicator.rep a do |_a|
|
896
|
+
org.rm_f _a, options
|
897
|
+
end
|
898
|
+
end
|
899
|
+
|
900
|
+
__hook__ :safe_unlink do |closure|
|
901
|
+
a, options = closure.args
|
902
|
+
options = {} if closure.args.size <= 1
|
903
|
+
PathReplicator.rep a do |_a|
|
904
|
+
org.safe_unlink _a, options
|
905
|
+
end
|
906
|
+
end
|
907
|
+
|
908
|
+
__hook__ :rm_r do |closure|
|
909
|
+
a, options = closure.args
|
910
|
+
options = {} if closure.args.size <= 1
|
911
|
+
PathReplicator.rep a do |_a|
|
912
|
+
org.rm_r _a, options
|
913
|
+
end
|
914
|
+
end
|
915
|
+
|
916
|
+
__hook__ :rm_rf do |closure|
|
917
|
+
a, options = closure.args
|
918
|
+
options = {} if closure.args.size <= 1
|
919
|
+
PathReplicator.rep a do |_a|
|
920
|
+
org.rm_rf _a, options
|
921
|
+
end
|
922
|
+
end
|
923
|
+
|
924
|
+
__hook__ :rmtree do |closure|
|
925
|
+
a, options = closure.args
|
926
|
+
options = {} if closure.args.size <= 1
|
927
|
+
PathReplicator.rep a do |_a|
|
928
|
+
org.rmtree _a, options
|
929
|
+
end
|
930
|
+
end
|
931
|
+
|
932
|
+
__hook__ :rmdir do |closure|
|
933
|
+
a, options = closure.args
|
934
|
+
options = {} if closure.args.size <= 1
|
935
|
+
PathReplicator.rep a do |_a|
|
936
|
+
org.rmdir _a, options
|
937
|
+
end
|
938
|
+
end
|
939
|
+
|
940
|
+
__hook__ :remove_entry do |closure|
|
941
|
+
a, force = closure.args
|
942
|
+
force = false if closure.args.size <= 1
|
943
|
+
PathReplicator.rep a do |_a|
|
944
|
+
org.remove_entry _a, force
|
945
|
+
end
|
946
|
+
end
|
947
|
+
|
948
|
+
__hook__ :remove_entry_secure do |closure|
|
949
|
+
a, force = closure.args
|
950
|
+
force = false if closure.args.size <= 1
|
951
|
+
PathReplicator.rep a do |_a|
|
952
|
+
org.remove_entry_secure _a, force
|
953
|
+
end
|
954
|
+
end
|
955
|
+
|
956
|
+
__hook__ :remove_file do |closure|
|
957
|
+
a, force = closure.args
|
958
|
+
force = false if closure.args.size <= 1
|
959
|
+
PathReplicator.rep a do |_a|
|
960
|
+
org.remove_file _a, force
|
961
|
+
end
|
962
|
+
end
|
963
|
+
|
964
|
+
__hook__ :touch do |closure|
|
965
|
+
a, options = closure.args
|
966
|
+
options = {} if closure.args.size <= 1
|
967
|
+
PathReplicator.rep a do |_a|
|
968
|
+
org.touch _a, options
|
969
|
+
end
|
970
|
+
PathReplicator.setModified(a)
|
971
|
+
end
|
972
|
+
|
973
|
+
end
|
974
|
+
|
975
|
+
|
976
|
+
class << Dir
|
977
|
+
org = PathReplicator::DirOrg
|
978
|
+
|
979
|
+
__hook__ :delete do |closure|
|
980
|
+
a = closure.args[0]
|
981
|
+
PathReplicator.rep a do |_a|
|
982
|
+
org.delete _a
|
983
|
+
end
|
984
|
+
end
|
985
|
+
|
986
|
+
__hook__ :rmdir do |closure|
|
987
|
+
a = closure.args[0]
|
988
|
+
PathReplicator.rep a do |_a|
|
989
|
+
org.rmdir _a
|
990
|
+
end
|
991
|
+
end
|
992
|
+
|
993
|
+
__hook__ :unlink do |closure|
|
994
|
+
a = closure.args[0]
|
995
|
+
PathReplicator.rep a do |_a|
|
996
|
+
org.unlink _a
|
997
|
+
end
|
998
|
+
end
|
999
|
+
|
1000
|
+
__hook__ :mkdir do |closure|
|
1001
|
+
a = closure.args
|
1002
|
+
PathReplicator.rep a[0] do |_a|
|
1003
|
+
org.mkdir _a, *a[1..-1]
|
1004
|
+
end
|
1005
|
+
PathReplicator.setModified(a[0])
|
1006
|
+
end
|
1007
|
+
|
1008
|
+
__hook__ :[] do |closure|
|
1009
|
+
args = closure.args
|
1010
|
+
glob(args)
|
1011
|
+
end
|
1012
|
+
|
1013
|
+
__hook__ :glob do |closure|
|
1014
|
+
args, *flgs = closure.args
|
1015
|
+
bl = closure.block
|
1016
|
+
if PathReplicator.set?
|
1017
|
+
if !args.is_a? Arrary
|
1018
|
+
args = [args]
|
1019
|
+
end
|
1020
|
+
args_rep = []
|
1021
|
+
args.each_index do |i|
|
1022
|
+
e = args[i]
|
1023
|
+
if e =~ /^\//
|
1024
|
+
if tmp = PathReplicator::FileOrg.is_in(e, PathReplicator.root)
|
1025
|
+
args[i] = "/" + tmp
|
1026
|
+
else
|
1027
|
+
e = PathReplicator.root + e
|
1028
|
+
end
|
1029
|
+
else
|
1030
|
+
pwd = org.pwd
|
1031
|
+
if pwd == "/"
|
1032
|
+
e = "/" + e
|
1033
|
+
else
|
1034
|
+
e = pwd + "/" + e
|
1035
|
+
end
|
1036
|
+
if tmp = PathReplicator::FileOrg.is_in(e, PathReplicator.root)
|
1037
|
+
args[i] = "/" + tmp
|
1038
|
+
else
|
1039
|
+
e = PathReplicator.root + e
|
1040
|
+
end
|
1041
|
+
end
|
1042
|
+
args_rep.push e
|
1043
|
+
end
|
1044
|
+
ret = []
|
1045
|
+
args.each do |e|
|
1046
|
+
ret += org.glob e, *flgs
|
1047
|
+
end
|
1048
|
+
args_rep.each do |e|
|
1049
|
+
ret += PathReplicator.rev org.glob(e, *flgs)
|
1050
|
+
end
|
1051
|
+
h = Hash.new
|
1052
|
+
ret.each do |e|
|
1053
|
+
if !PathReplicator.deleted?(e)
|
1054
|
+
h[e] = true
|
1055
|
+
end
|
1056
|
+
end
|
1057
|
+
ret = h.keys
|
1058
|
+
if block_given?
|
1059
|
+
ret.each do |e|
|
1060
|
+
bl.call e
|
1061
|
+
end
|
1062
|
+
ret
|
1063
|
+
else
|
1064
|
+
ret
|
1065
|
+
end
|
1066
|
+
else
|
1067
|
+
org.glob args, *flgs, &bl
|
1068
|
+
end
|
1069
|
+
end
|
1070
|
+
|
1071
|
+
__hook__ :foreach do |closure|
|
1072
|
+
path = closure.args[0]
|
1073
|
+
if PathReplicator.set?
|
1074
|
+
hash = Hash.new
|
1075
|
+
if tmp = File.is_in(path, PathReplicator.root)
|
1076
|
+
path = "/" + tmp
|
1077
|
+
end
|
1078
|
+
if PathReplicator::FileOrg.directory? path
|
1079
|
+
org.foreach path do |f|
|
1080
|
+
if f != ".." && f != "."
|
1081
|
+
hash[f] = true
|
1082
|
+
end
|
1083
|
+
end
|
1084
|
+
end
|
1085
|
+
if PathReplicator::FileOrg.directory?(tmp = PathReplicator.root + PathReplicator::FileOrg.expand_path(path))
|
1086
|
+
org.foreach tmp do |f|
|
1087
|
+
if f != ".." && f != "."
|
1088
|
+
hash[f] = true
|
1089
|
+
end
|
1090
|
+
end
|
1091
|
+
end
|
1092
|
+
if path == "/"
|
1093
|
+
path = ""
|
1094
|
+
yield ".."
|
1095
|
+
end
|
1096
|
+
yield "."
|
1097
|
+
hash.keys.each do |e|
|
1098
|
+
if !PathReplicator.deleted?(path + "/" + e)
|
1099
|
+
yield e
|
1100
|
+
end
|
1101
|
+
end
|
1102
|
+
else
|
1103
|
+
org.foreach path do |e|
|
1104
|
+
yield e
|
1105
|
+
end
|
1106
|
+
end
|
1107
|
+
end
|
1108
|
+
|
1109
|
+
__hook__ :chdir do |closure|
|
1110
|
+
path = closure.args[0]
|
1111
|
+
org.chdir PathReplicator[path]
|
1112
|
+
end
|
1113
|
+
|
1114
|
+
__hook__ :chroot do |closure|
|
1115
|
+
path = closure.args[0]
|
1116
|
+
org.chroot PathReplicator[path]
|
1117
|
+
end
|
1118
|
+
|
1119
|
+
__hook__ :entries do |closure|
|
1120
|
+
path = closure.args[0]
|
1121
|
+
ret = []
|
1122
|
+
foreach path do |e|
|
1123
|
+
ret.push e
|
1124
|
+
end
|
1125
|
+
ret
|
1126
|
+
end
|
1127
|
+
|
1128
|
+
__hook__ :getwd do |closure|
|
1129
|
+
arg = closure.args
|
1130
|
+
ret = PathReplicator.rev(org.getwd)
|
1131
|
+
ret
|
1132
|
+
end
|
1133
|
+
|
1134
|
+
__hook__ :getwd do |closure|
|
1135
|
+
arg = closure.args
|
1136
|
+
org.getwd(*arg)
|
1137
|
+
end
|
1138
|
+
|
1139
|
+
end
|
1140
|
+
|
1141
|
+
|
1142
|
+
class << FileTest
|
1143
|
+
org = FileTest.__hook_group
|
1144
|
+
|
1145
|
+
__hook__ :blockdev? do |closure|
|
1146
|
+
path = closrue.args[0]
|
1147
|
+
org.blockdev? PathReplicator[path]
|
1148
|
+
end
|
1149
|
+
|
1150
|
+
__hook__ :chardev? do |closure|
|
1151
|
+
path = closrue.args[0]
|
1152
|
+
org.chardev? PathReplicator[path]
|
1153
|
+
end
|
1154
|
+
|
1155
|
+
__hook__ :directory? do |closure|
|
1156
|
+
path = closrue.args[0]
|
1157
|
+
org.directory? PathReplicator[path]
|
1158
|
+
end
|
1159
|
+
|
1160
|
+
__hook__ :executable? do |closure|
|
1161
|
+
path = closrue.args[0]
|
1162
|
+
org.executable? PathReplicator[path]
|
1163
|
+
end
|
1164
|
+
|
1165
|
+
__hook__ :executable_real? do |closure|
|
1166
|
+
path = closrue.args[0]
|
1167
|
+
org.executable_real? PathReplicator[path]
|
1168
|
+
end
|
1169
|
+
|
1170
|
+
__hook__ :exist? do |closure|
|
1171
|
+
path = closrue.args[0]
|
1172
|
+
org.exist? PathReplicator[path]
|
1173
|
+
end
|
1174
|
+
|
1175
|
+
__hook__ :exist? do |closure|
|
1176
|
+
path = closrue.args[0]
|
1177
|
+
org.exist? PathReplicator[path]
|
1178
|
+
end
|
1179
|
+
|
1180
|
+
__hook__ :file? do |closure|
|
1181
|
+
path = closrue.args[0]
|
1182
|
+
org.file? PathReplicator[path]
|
1183
|
+
end
|
1184
|
+
|
1185
|
+
__hook__ :grpowned? do |closure|
|
1186
|
+
path = closrue.args[0]
|
1187
|
+
org.grpowned? PathReplicator[path]
|
1188
|
+
end
|
1189
|
+
|
1190
|
+
__hook__ :owned? do |closure|
|
1191
|
+
path = closrue.args[0]
|
1192
|
+
org.owned? PathReplicator[path]
|
1193
|
+
end
|
1194
|
+
|
1195
|
+
__hook__ :identical? do |closure|
|
1196
|
+
path1, path2 = closure.args
|
1197
|
+
org.identical? PathReplicator[path1], PathReplicator[path2]
|
1198
|
+
end
|
1199
|
+
|
1200
|
+
__hook__ :pipe? do |closure|
|
1201
|
+
path = closrue.args[0]
|
1202
|
+
org.pipe? PathReplicator[path]
|
1203
|
+
end
|
1204
|
+
|
1205
|
+
__hook__ :readable? do |closure|
|
1206
|
+
path = closrue.args[0]
|
1207
|
+
org.readable? PathReplicator[path]
|
1208
|
+
end
|
1209
|
+
|
1210
|
+
__hook__ :readable_real? do |closure|
|
1211
|
+
path = closrue.args[0]
|
1212
|
+
org.readable_real? PathReplicator[path]
|
1213
|
+
end
|
1214
|
+
|
1215
|
+
__hook__ :setgid? do |closure|
|
1216
|
+
path = closrue.args[0]
|
1217
|
+
org.setgid? PathReplicator[path]
|
1218
|
+
end
|
1219
|
+
|
1220
|
+
__hook__ :setuid? do |closure|
|
1221
|
+
path = closrue.args[0]
|
1222
|
+
org.setuid? PathReplicator[path]
|
1223
|
+
end
|
1224
|
+
|
1225
|
+
__hook__ :size do |closure|
|
1226
|
+
path = closrue.args[0]
|
1227
|
+
org.size PathReplicator[path]
|
1228
|
+
end
|
1229
|
+
|
1230
|
+
__hook__ :size? do |closure|
|
1231
|
+
path = closrue.args[0]
|
1232
|
+
org.size? PathReplicator[path]
|
1233
|
+
end
|
1234
|
+
|
1235
|
+
__hook__ :socket? do |closure|
|
1236
|
+
path = closrue.args[0]
|
1237
|
+
org.socket? PathReplicator[path]
|
1238
|
+
end
|
1239
|
+
|
1240
|
+
__hook__ :sticky? do |closure|
|
1241
|
+
path = closrue.args[0]
|
1242
|
+
org.sticky? PathReplicator[path]
|
1243
|
+
end
|
1244
|
+
|
1245
|
+
__hook__ :symlink? do |closure|
|
1246
|
+
path = closrue.args[0]
|
1247
|
+
org.symlink? PathReplicator[path]
|
1248
|
+
end
|
1249
|
+
|
1250
|
+
__hook__ :writable? do |closure|
|
1251
|
+
path = closrue.args[0]
|
1252
|
+
org.writable? PathReplicator[path]
|
1253
|
+
end
|
1254
|
+
|
1255
|
+
__hook__ :writable_real? do |closure|
|
1256
|
+
path = closrue.args[0]
|
1257
|
+
org.writable_real? PathReplicator[path]
|
1258
|
+
end
|
1259
|
+
|
1260
|
+
__hook__ :zero? do |closure|
|
1261
|
+
path = closrue.args[0]
|
1262
|
+
org.zero? PathReplicator[path]
|
1263
|
+
end
|
1264
|
+
|
1265
|
+
end
|
1266
|
+
|
1267
|
+
|