0
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
| |
commandLineOption = ""
maxsize = 20
public A(1,2) A(0,0) = "<(?:HTML|HEAD|BODY|TITLE|PRE|TABLE|IMG|SCRIPT)"
A(0,1) = true
A(0,2) = "html"
A(1,0) = "perl|[$%]ENV{"
A(1,1) = false
A(1,2) = "pl"
set arguments = WScript.Arguments
set wshShell = CreateObject("WScript.Shell")
set fso = CreateObject("Scripting.FileSystemObject")
path = fso.GetParentFolderName(Wscript.ScriptFullName)
sakura = quote(path + "\sakura.exe") + " " + commandLineOption
if 0 < arguments.count then
for i = 0 to (arguments.count - 1)
if (fso.GetFile(arguments.Item(i)).Size / 1024 / 1024) > maxsize then
if wshshell.popup("「" & arguments.Item(i) & "」" & Chr(13) & "のファイルサイズは 【約 " & Fix(fso.GetFile(arguments.Item(i)).Size / 1024 / 1024 * 100) /100 & " MiB】 です。" & Chr(13) & "メモリを大量に消費する可能性がありますが、開いてもよろしいでしょうか?", 0, maxsize & " MiB を超えるファイル", 49) = 1 then
go = true
else
go = false
end if
else
go = true
end if
if go then
typeOption = ""
set file = fso.OpenTextFile(arguments.Item(i), 1)
if fso.GetFile(arguments.Item(i)).Size > 254 then
str = file.Read(255)
else
str = file.Read(fso.GetFile(arguments.Item(i)).Size)
end if
set reg = new RegExp
reg.Pattern = " EditType=([^ \r\n\t]+)"
reg.IgnoreCase = true
reg.Multiline = true
if reg.Test(str) then typeOption = reg.Execute(str)(0).SubMatches(0)
if LenB(typeOption) = 0 then
for j = 0 to UBound(A)
set reg = new RegExp
reg.Pattern = A(j, 0)
reg.IgnoreCase = A(j, 1)
reg.Multiline = true
if reg.Test(str) then
typeOption = A(j, 2)
exit for
end if
next
end if
wshShell.Exec sakura + " " + quote(arguments.Item(i)) + " -TYPE=" + typeOption
file.Close()
end if
next
else
wshShell.Exec sakura
end if
function quote(text)
quote = """" + text + """"
end function
|