-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathBiliFile.rb
More file actions
52 lines (40 loc) · 781 Bytes
/
BiliFile.rb
File metadata and controls
52 lines (40 loc) · 781 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
module BiliFile
require 'fileutils'
def biliMove(file, newfile=file, condition)
tmp = file + ".tmp"
open(file, 'r') do |f0|
open(tmp, 'w') do |f1|
f0.each_line do |line|
status = true
code = eval(condition)
if code != nil then
if code == false then
status = false
else
if code != true then
if code > 0 then
status = true
else
status = false
end
else
status = true
end
end
else
status = false
end
f1.write(line) if status
end
end
end
if newfile == file then
oldfile = file + ".old"
FileUtils.mv file, oldfile
end
FileUtils.mv tmp, newfile
end
def biliTouch(file="")
open(file, 'w').close
end
end