rwdmovies 0.6 → 0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. data/Readme.txt +47 -30
  2. data/code/ag1core/aa0begin.rb +18 -18
  3. data/code/ag1core/rwdtinkerversion.rb +15 -15
  4. data/code/xa5rwdtinkercallable/callable.rb +12 -12
  5. data/code/xb1rwdtinkerbackwindow/diagnostictab.rb +21 -21
  6. data/code/xb1rwdtinkerbackwindow/{lm1installapplet.rb → installapplet.rb} +21 -20
  7. data/code/xb1rwdtinkerbackwindow/{05listinstalledfiles.rb → listinstalledfiles.rb} +1 -1
  8. data/code/xb1rwdtinkerbackwindow/{ll5listzips.rb → listzips.rb} +9 -7
  9. data/code/xb1rwdtinkerbackwindow/loadconfigurationrecord.rb +32 -0
  10. data/code/xb1rwdtinkerbackwindow/loadconfigurationvariables.rb +13 -0
  11. data/code/xb1rwdtinkerbackwindow/{ll1openname.rb → openappletname.rb} +18 -18
  12. data/code/xb1rwdtinkerbackwindow/{mm1removeapplet.rb → removeapplet.rb} +28 -28
  13. data/code/xb1rwdtinkerbackwindow/rwdtinkerwin2version.rb +14 -14
  14. data/code/xb1rwdtinkerbackwindow/saveconfigurationrecord.rb +18 -0
  15. data/code/zz0applicationend/zz0end.rb +4 -4
  16. data/configuration/language.cnf +5 -0
  17. data/configuration/rwdmovies.cnf +0 -1
  18. data/configuration/rwdmoviesversion.cnf +2 -0
  19. data/configuration/rwdplayscriptsversion.cnf +2 -0
  20. data/configuration/rwdtinker.cnf +12 -0
  21. data/configuration/rwdtinkerversion.cnf +2 -0
  22. data/configuration/tinkerwin2variables.cnf +8 -0
  23. data/configuration/tinkerwin2version.cnf +3 -0
  24. data/ev/browser.rb +109 -109
  25. data/ev/ftools.rb +170 -170
  26. data/ev/net.rb +750 -750
  27. data/ev/ruby.rb +819 -819
  28. data/ev/rwd.rb +1848 -1848
  29. data/ev/sgml.rb +236 -236
  30. data/ev/thread.rb +63 -63
  31. data/ev/tree.rb +343 -343
  32. data/ev/xml.rb +4 -4
  33. data/gui/00coreguibegin/applicationguitop.rwd +4 -0
  34. data/gui/{ee1rwdmovies → frontwindow0/superant.com.rwdmovies}/1openmoviedata.rwd +0 -0
  35. data/gui/{ee1rwdmovies → frontwindow0/superant.com.rwdmovies}/2openmoviephoto.rwd +0 -0
  36. data/gui/{ee1rwdmovies → frontwindow0/superant.com.rwdmovies}/3listmoviegfiles.rwd +0 -0
  37. data/gui/{ee1rwdmovies → frontwindow0/superant.com.rwdmovies}/6editrecord.rwd +0 -0
  38. data/gui/{ee1rwdmovies → frontwindow0/superant.com.rwdmovies}/movieutilities.rwd +0 -0
  39. data/gui/{ee1rwdmovies → frontwindow0/superant.com.rwdmovies}/viewconfiguration.rwd +0 -0
  40. data/gui/{ll1selectiontabbegin → frontwindowselectionbegin/selectiontabbegin}/selectiontabbegin.rwd +16 -16
  41. data/gui/{ll5rwdtinkerwin2selectiontab → frontwindowselections/superant.com.rwdtinkerwin2selectiontab}/rwdwin2selectiontab.rwd +12 -12
  42. data/gui/{lz1selectiontabend/endselectiontab.rwd → frontwindowselectionzend/viewselectionzend/viewselectionend.rwd} +3 -3
  43. data/gui/{tt0documentsbegin → frontwindowtdocumentbegin/superant.com.documentsbegin}/tt0documentbegin.rwd +6 -6
  44. data/gui/{uu5rwddocuments → frontwindowtdocuments/superant.com.documents}/uu5documents.rwd +15 -15
  45. data/gui/{uv7rwdmovies → frontwindowtdocuments/superant.com.rwdmovies}/uv7docmovies.rwd +0 -0
  46. data/gui/{uu6rwdtinkerwin2documents → frontwindowtdocuments/superant.com.tinkerwin2documents}/uu5documents.rwd +6 -6
  47. data/gui/{ww0documentsend → frontwindowtdocumentzend/superant.com.documentsend}/ww0documentend.rwd +7 -7
  48. data/gui/{wz6finaltabs → frontwindowz1end/frontwindowend}/xx0rwdfirsttab.rwd +6 -6
  49. data/gui/{ya1helpaboutbegin → helpaboutbegin/superant.com.helpaboutbegin}/ya0helpscreenstart.rwd +3 -3
  50. data/gui/{yl2rwdmovieshelpabout → helpaboutinstalled/superant.com.rwdmovieshelpabout}/1movies.rwd +0 -0
  51. data/gui/{yl2rwdmovieshelpabout → helpaboutinstalled/superant.com.rwdmovieshelpabout}/2movies.rwd +0 -0
  52. data/gui/{yl2rwdmovieshelpabout → helpaboutinstalled/superant.com.rwdmovieshelpabout}/5version.rwd +0 -0
  53. data/gui/{yg6rwdwin2helpabout → helpaboutinstalled/superant.com.rwdwin2helpabout}/1appname.rwd +4 -4
  54. data/gui/{yg5rwdhelpabout → helpaboutinstalled/superant.com.rwdwin2helpabout}/3copyright.rwd +3 -3
  55. data/gui/{yg6rwdwin2helpabout → helpaboutinstalled/superant.com.rwdwin2helpabout}/5version.rwd +10 -10
  56. data/gui/{yg5rwdhelpabout → helpaboutinstalled/superant.com.tinkerhelpabout}/1appname.rwd +4 -4
  57. data/gui/{yg6rwdwin2helpabout → helpaboutinstalled/superant.com.tinkerhelpabout}/3copyright.rwd +3 -3
  58. data/gui/helpaboutinstalled/superant.com.tinkerhelpabout/5version.rwd +10 -0
  59. data/gui/helpaboutzend/superant.com.helpaboutend/helpscreenend.rwd +3 -0
  60. data/gui/{xx8rwdmoviespicture → tinkerbackwindows/superant.com.rwdmoviespicture}/xx8moviephotoview.rwd +0 -0
  61. data/gui/{xa5rwdtinkercallablewindow → tinkerbackwindows/superant.com.tinercallablewindow}/1appname.rwd +17 -17
  62. data/gui/{xa5rwdtinkercallablewindow → tinkerbackwindows/superant.com.tinercallablewindow}/9end.rwd +4 -4
  63. data/gui/{xb1rwdtinkerbackwindow → tinkerbackwindows/superant.com.tinkerbackwindow}/1appname.rwd +5 -5
  64. data/gui/{xb1rwdtinkerbackwindow → tinkerbackwindows/superant.com.tinkerbackwindow}/3arwddiagnostics.rwd +33 -33
  65. data/gui/tinkerbackwindows/superant.com.tinkerbackwindow/40editconfiguration.rwd +36 -0
  66. data/gui/{xb1rwdtinkerbackwindow/4arwdlistapplets.rwd → tinkerbackwindows/superant.com.tinkerbackwindow/50rwdlistapplets.rwd} +44 -44
  67. data/gui/{xb1rwdtinkerbackwindow/4arwdlistzips.rwd → tinkerbackwindows/superant.com.tinkerbackwindow/50rwdlistzips.rwd} +35 -35
  68. data/gui/{xb1rwdtinkerbackwindow/2tab1.rwd → tinkerbackwindows/superant.com.tinkerbackwindow/80tab1.rwd} +11 -11
  69. data/gui/{xb1rwdtinkerbackwindow → tinkerbackwindows/superant.com.tinkerbackwindow}/9backend.rwd +6 -6
  70. data/gui/{xa1versionwindow → tinkerbackwindows/superant.com.versionwindow}/1appname.rwd +19 -19
  71. data/gui/{za1applicationend → zzcoreguiend/tinkerapplicationguiend}/yy9rwdend.rwd +4 -4
  72. data/init.rb +233 -233
  73. data/installed/rwdtinkerwin2-0.5.inf +8 -8
  74. data/installed/rwdviewlogo-0.4.inf +4 -0
  75. data/lang/alanguagehashbegin.rb +4 -4
  76. data/lang/en/rwdcore/languagefile.rb +15 -15
  77. data/lang/es/rwdcore/languagefile-es.rb +14 -14
  78. data/lang/jp/rwdcore/languagefile.rb +9 -0
  79. data/lang/languagehash.rb +4 -4
  80. data/lang/nl/rwdcore/languagefile.rb +19 -0
  81. data/lang/templangfile.rb +15 -21
  82. data/lang/vlanguagehashend.rb +6 -6
  83. data/lang/wlocallangstart.rb +5 -5
  84. data/lang/xlocallangfile.rb +16 -10
  85. data/lang/zlocallangend.rb +2 -2
  86. data/lib/temp.rb +1 -1
  87. data/rwd_files/HowTo_Movies.txt +2 -0
  88. data/rwd_files/HowTo_Tinker.txt +318 -276
  89. data/rwd_files/HowTo_TinkerWin2.txt +202 -202
  90. data/rwd_files/Readme.txt +57 -57
  91. data/rwd_files/moviestmp.jpg +0 -0
  92. data/rwd_files/rdoc-style.css +174 -174
  93. data/rwd_files/rwdapplications.html +54 -54
  94. data/rwd_files/tinker.png +0 -0
  95. data/tests/rwdtinkertestEN.rb +163 -0
  96. data/tests/test.result +32 -0
  97. data/tests/totranslate.lang +93 -93
  98. data/zips/rwdahelloworld-0.5.zip +0 -0
  99. metadata +96 -75
  100. data/code/gh9calendar/gh9calendar.rb +0 -16
  101. data/configuration/aa0rwdframework.cnf +0 -14
  102. data/configuration/ab1tinkerwin2.cnf +0 -4
  103. data/gui/aa2core/aa0rwdtop.rwd +0 -4
  104. data/gui/yg5rwdhelpabout/5version.rwd +0 -10
  105. data/gui/yy5helpaboutend/helpscreenend.rwd +0 -3
  106. data/installed/rubyslippers-0.94.inf +0 -9
  107. data/installed/rwdcalendar-0.5.inf +0 -8
  108. data/lang/en/rwdcalendar/calendar-nl.rb +0 -6
  109. data/lang/es/rwdcalendar/calendar-nl.rb +0 -6
  110. data/lang/nl/rwdcalendar/calendar-nl.rb +0 -6
  111. data/lang/nl/rwdcore/languagefile-nl.rb +0 -4
  112. data/zips/rwdacalendar-0.5.zip +0 -0
  113. data/zips/rwdhelloworld-0.3.zip +0 -0
  114. data/zips/rwdwshell-0.91.zip +0 -0
  115. data/zips/wrubyslippers-0.93.zip +0 -0
data/ev/browser.rb CHANGED
@@ -1,109 +1,109 @@
1
- require "ev/ruby"
2
- require "ev/net"
3
-
4
- begin
5
- require "win32ole"
6
- require "win32/registry"
7
- rescue LoadError
8
- $".push "win32ole.so"
9
- $".push "win32/registry.rb"
10
- end
11
-
12
- def windowsbrowser
13
- $stderr.puts "Looking for default browser..."
14
-
15
- filetype = "htmlfile"
16
- application = nil
17
-
18
- begin
19
- Win32::Registry::HKEY_CLASSES_ROOT.open('.html') do |reg|
20
- filetype = reg[""]
21
- end
22
-
23
- Win32::Registry::HKEY_CLASSES_ROOT.open(filetype + '\shell\open\command') do |reg|
24
- application = reg[""]
25
- end
26
- rescue NameError
27
- $stderr.puts "Only available for Windows."
28
- end
29
-
30
- application
31
- end
32
-
33
- def linuxbrowser
34
- application = ""
35
-
36
- application = `which galeon 2> /dev/null`.chomp if application.empty?
37
- application = `which mozilla 2> /dev/null`.chomp if application.empty?
38
- application = `which firefox 2> /dev/null`.chomp if application.empty?
39
- application = `which opera 2> /dev/null`.chomp if application.empty?
40
- application = `which konqueror 2> /dev/null`.chomp if application.empty?
41
- application = `which htmlview 2> /dev/null`.chomp if application.empty?
42
- application = nil if application.empty?
43
-
44
- application
45
- end
46
-
47
- def defaultbrowser
48
- res = nil
49
- res = windowsbrowser if windows?
50
- res = linuxbrowser if linux?
51
- res
52
- end
53
-
54
- def showinbrowser(html, browser=defaultbrowser)
55
- port, io = TCPServer.freeport(7701, 7709)
56
-
57
- unless browser.nil?
58
- Thread.new do
59
- begin
60
- #command = "1234 \"http://localhost:#{port}\"" if linux?
61
- #command = "L:/prog/MozillaFirefox/firefox.exe \"http://localhost:#{port}\"" if cygwin?
62
- #command = Win32::Registry::HKEY_CLASSES_ROOT.open('htmlfile\shell\open\command')[0] + " \"http://localhost:#{port}/\"" if windows?
63
-
64
- command = "#{browser} \"http://localhost:#{port}\""
65
-
66
- Thread.pass
67
-
68
- system(command)
69
- rescue
70
- end
71
- end
72
- end
73
-
74
- HTTPServer.serve([port, io]) do |req, resp|
75
- resp << html
76
-
77
- resp.stop
78
- end
79
- end
80
-
81
- def tab2html(tab)
82
- res = ""
83
-
84
- tab = tab.to_html(false)
85
-
86
- res << "<html>\n"
87
- res << "<body>\n"
88
- res << "<table align='center' border='1' cellspacing='0' cellpadding='3'>\n"
89
- res << "<tbody>\n"
90
-
91
- tab.split(/\r*\n/).each do |line|
92
- res << "<tr>\n"
93
-
94
- line.split(/\t/, -1).each do |veld|
95
- veld = "&nbsp;" if veld.compress.empty?
96
-
97
- res << "<td>%s</td>\n" % veld
98
- end
99
-
100
- res << "</tr>\n"
101
- end
102
-
103
- res << "</tbody>\n"
104
- res << "</table>\n"
105
- res << "</body>\n"
106
- res << "</html>\n"
107
-
108
- res
109
- end
1
+ require "ev/ruby"
2
+ require "ev/net"
3
+
4
+ begin
5
+ require "win32ole"
6
+ require "win32/registry"
7
+ rescue LoadError
8
+ $".push "win32ole.so"
9
+ $".push "win32/registry.rb"
10
+ end
11
+
12
+ def windowsbrowser
13
+ $stderr.puts "Looking for default browser..."
14
+
15
+ filetype = "htmlfile"
16
+ application = nil
17
+
18
+ begin
19
+ Win32::Registry::HKEY_CLASSES_ROOT.open('.html') do |reg|
20
+ filetype = reg[""]
21
+ end
22
+
23
+ Win32::Registry::HKEY_CLASSES_ROOT.open(filetype + '\shell\open\command') do |reg|
24
+ application = reg[""]
25
+ end
26
+ rescue NameError
27
+ $stderr.puts "Only available for Windows."
28
+ end
29
+
30
+ application
31
+ end
32
+
33
+ def linuxbrowser
34
+ application = ""
35
+
36
+ application = `which galeon 2> /dev/null`.chomp if application.empty?
37
+ application = `which mozilla 2> /dev/null`.chomp if application.empty?
38
+ application = `which firefox 2> /dev/null`.chomp if application.empty?
39
+ application = `which opera 2> /dev/null`.chomp if application.empty?
40
+ application = `which konqueror 2> /dev/null`.chomp if application.empty?
41
+ application = `which htmlview 2> /dev/null`.chomp if application.empty?
42
+ application = nil if application.empty?
43
+
44
+ application
45
+ end
46
+
47
+ def defaultbrowser
48
+ res = nil
49
+ res = windowsbrowser if windows?
50
+ res = linuxbrowser if linux?
51
+ res
52
+ end
53
+
54
+ def showinbrowser(html, browser=defaultbrowser)
55
+ port, io = TCPServer.freeport(7701, 7709)
56
+
57
+ unless browser.nil?
58
+ Thread.new do
59
+ begin
60
+ #command = "1234 \"http://localhost:#{port}\"" if linux?
61
+ #command = "L:/prog/MozillaFirefox/firefox.exe \"http://localhost:#{port}\"" if cygwin?
62
+ #command = Win32::Registry::HKEY_CLASSES_ROOT.open('htmlfile\shell\open\command')[0] + " \"http://localhost:#{port}/\"" if windows?
63
+
64
+ command = "#{browser} \"http://localhost:#{port}\""
65
+
66
+ Thread.pass
67
+
68
+ system(command)
69
+ rescue
70
+ end
71
+ end
72
+ end
73
+
74
+ HTTPServer.serve([port, io]) do |req, resp|
75
+ resp << html
76
+
77
+ resp.stop
78
+ end
79
+ end
80
+
81
+ def tab2html(tab)
82
+ res = ""
83
+
84
+ tab = tab.to_html(false)
85
+
86
+ res << "<html>\n"
87
+ res << "<body>\n"
88
+ res << "<table align='center' border='1' cellspacing='0' cellpadding='3'>\n"
89
+ res << "<tbody>\n"
90
+
91
+ tab.split(/\r*\n/).each do |line|
92
+ res << "<tr>\n"
93
+
94
+ line.split(/\t/, -1).each do |veld|
95
+ veld = "&nbsp;" if veld.compress.empty?
96
+
97
+ res << "<td>%s</td>\n" % veld
98
+ end
99
+
100
+ res << "</tr>\n"
101
+ end
102
+
103
+ res << "</tbody>\n"
104
+ res << "</table>\n"
105
+ res << "</body>\n"
106
+ res << "</html>\n"
107
+
108
+ res
109
+ end
data/ev/ftools.rb CHANGED
@@ -1,170 +1,170 @@
1
- require "ftools"
2
-
3
- class Dir
4
- def self.mkdirrec(dir)
5
- pdir = File.dirname(dir)
6
-
7
- if not pdir.empty? and not File.directory?(pdir)
8
- Dir.mkdirrec(pdir)
9
- end
10
-
11
- Dir.mkdir(dir) rescue nil
12
- end
13
-
14
- def self.copy(from, to)
15
- if File.directory?(from)
16
- pdir = Dir.pwd
17
- todir = File.expand_path(to)
18
-
19
- mkdirrec(todir)
20
-
21
- Dir.chdir(from)
22
- Dir.new(".").each do |e|
23
- Dir.copy(e, todir+"/"+e) if not [".", ".."].include?(e)
24
- end
25
- Dir.chdir(pdir)
26
- else
27
- todir = File.dirname(File.expand_path(to))
28
-
29
- mkdirrec(todir)
30
-
31
- File.copy(from, to)
32
- end
33
- end
34
-
35
- def self.move(from, to)
36
- Dir.copy(from, to)
37
- Dir.rm_rf(from)
38
- end
39
-
40
- def self.rm_rf(entry)
41
- if File.ftype(entry) == "directory"
42
- pdir = Dir.pwd
43
-
44
- Dir.chdir(entry)
45
- Dir.new(".").each do |e|
46
- Dir.rm_rf(e) if not [".", ".."].include?(e)
47
- end
48
- Dir.chdir(pdir)
49
-
50
- Dir.delete(entry)
51
- else
52
- File.delete(entry)
53
- end
54
- end
55
-
56
- def self.find(entry=nil, mask=nil)
57
- entry = "." if entry.nil?
58
-
59
- entry = entry.gsub!(/[\/\\]*$/, "") unless entry.nil?
60
-
61
- mask = /^#{mask}$/i if mask.kind_of?(String)
62
-
63
- res = []
64
-
65
- if File.directory?(entry)
66
- pdir = Dir.pwd
67
-
68
- res += ["%s/" % entry] if mask.nil? or entry =~ mask
69
-
70
- begin
71
- Dir.chdir(entry)
72
-
73
- begin
74
- Dir.new(".").each do |e|
75
- res += Dir.find(e, mask).collect{|e| entry+"/"+e} unless [".", ".."].include?(e)
76
- end
77
- ensure
78
- Dir.chdir(pdir)
79
- end
80
- rescue Errno::EACCES => error
81
- puts error
82
- end
83
- else
84
- res += [entry] if mask.nil? or entry =~ mask
85
- end
86
-
87
- res
88
- end
89
- end
90
-
91
- class File
92
- def self.rollbackup(file, mode=nil)
93
- backupfile = file + ".RB.BACKUP"
94
- controlfile = file + ".RB.CONTROL"
95
- res = nil
96
-
97
- File.touch(file) unless File.file?(file)
98
-
99
- # Rollback
100
-
101
- if File.file?(backupfile) and File.file?(controlfile)
102
- $stdout.puts "Restoring #{file}..."
103
-
104
- File.copy(backupfile, file) # Rollback from phase 3
105
- end
106
-
107
- # Reset
108
-
109
- File.delete(backupfile) if File.file?(backupfile) # Reset from phase 2 or 3
110
- File.delete(controlfile) if File.file?(controlfile) # Reset from phase 3 or 4
111
-
112
- # Backup
113
-
114
- File.copy(file, backupfile) # Enter phase 2
115
- File.touch(controlfile) # Enter phase 3
116
-
117
- # The real thing
118
-
119
- if block_given?
120
- if mode.nil?
121
- res = yield
122
- else
123
- File.open(file, mode) do |f|
124
- res = yield(f)
125
- end
126
- end
127
- end
128
-
129
- # Cleanup
130
-
131
- File.delete(backupfile) # Enter phase 4
132
- File.delete(controlfile) # Enter phase 5
133
-
134
- # Return, like File.open
135
-
136
- res = File.open(file, (mode or "r")) unless block_given?
137
-
138
- res
139
- end
140
-
141
- def self.touch(file)
142
- File.open(file, "a"){|f|}
143
- end
144
-
145
- def self.which(file)
146
- res = nil
147
-
148
- if windows?
149
- file = file.gsub(/\.exe$/i, "") + ".exe"
150
- sep = ";"
151
- else
152
- sep = ":"
153
- end
154
-
155
- catch :stop do
156
- ENV["PATH"].split(/#{sep}/).reverse.each do |d|
157
- if File.directory?(d)
158
- Dir.new(d).each do |e|
159
- if e.downcase == file.downcase
160
- res = File.expand_path(e, d)
161
- throw :stop
162
- end
163
- end
164
- end
165
- end
166
- end
167
-
168
- res
169
- end
170
- end
1
+ require "ftools"
2
+
3
+ class Dir
4
+ def self.mkdirrec(dir)
5
+ pdir = File.dirname(dir)
6
+
7
+ if not pdir.empty? and not File.directory?(pdir)
8
+ Dir.mkdirrec(pdir)
9
+ end
10
+
11
+ Dir.mkdir(dir) rescue nil
12
+ end
13
+
14
+ def self.copy(from, to)
15
+ if File.directory?(from)
16
+ pdir = Dir.pwd
17
+ todir = File.expand_path(to)
18
+
19
+ mkdirrec(todir)
20
+
21
+ Dir.chdir(from)
22
+ Dir.new(".").each do |e|
23
+ Dir.copy(e, todir+"/"+e) if not [".", ".."].include?(e)
24
+ end
25
+ Dir.chdir(pdir)
26
+ else
27
+ todir = File.dirname(File.expand_path(to))
28
+
29
+ mkdirrec(todir)
30
+
31
+ File.copy(from, to)
32
+ end
33
+ end
34
+
35
+ def self.move(from, to)
36
+ Dir.copy(from, to)
37
+ Dir.rm_rf(from)
38
+ end
39
+
40
+ def self.rm_rf(entry)
41
+ if File.ftype(entry) == "directory"
42
+ pdir = Dir.pwd
43
+
44
+ Dir.chdir(entry)
45
+ Dir.new(".").each do |e|
46
+ Dir.rm_rf(e) if not [".", ".."].include?(e)
47
+ end
48
+ Dir.chdir(pdir)
49
+
50
+ Dir.delete(entry)
51
+ else
52
+ File.delete(entry)
53
+ end
54
+ end
55
+
56
+ def self.find(entry=nil, mask=nil)
57
+ entry = "." if entry.nil?
58
+
59
+ entry = entry.gsub!(/[\/\\]*$/, "") unless entry.nil?
60
+
61
+ mask = /^#{mask}$/i if mask.kind_of?(String)
62
+
63
+ res = []
64
+
65
+ if File.directory?(entry)
66
+ pdir = Dir.pwd
67
+
68
+ res += ["%s/" % entry] if mask.nil? or entry =~ mask
69
+
70
+ begin
71
+ Dir.chdir(entry)
72
+
73
+ begin
74
+ Dir.new(".").each do |e|
75
+ res += Dir.find(e, mask).collect{|e| entry+"/"+e} unless [".", ".."].include?(e)
76
+ end
77
+ ensure
78
+ Dir.chdir(pdir)
79
+ end
80
+ rescue Errno::EACCES => error
81
+ puts error
82
+ end
83
+ else
84
+ res += [entry] if mask.nil? or entry =~ mask
85
+ end
86
+
87
+ res
88
+ end
89
+ end
90
+
91
+ class File
92
+ def self.rollbackup(file, mode=nil)
93
+ backupfile = file + ".RB.BACKUP"
94
+ controlfile = file + ".RB.CONTROL"
95
+ res = nil
96
+
97
+ File.touch(file) unless File.file?(file)
98
+
99
+ # Rollback
100
+
101
+ if File.file?(backupfile) and File.file?(controlfile)
102
+ $stdout.puts "Restoring #{file}..."
103
+
104
+ File.copy(backupfile, file) # Rollback from phase 3
105
+ end
106
+
107
+ # Reset
108
+
109
+ File.delete(backupfile) if File.file?(backupfile) # Reset from phase 2 or 3
110
+ File.delete(controlfile) if File.file?(controlfile) # Reset from phase 3 or 4
111
+
112
+ # Backup
113
+
114
+ File.copy(file, backupfile) # Enter phase 2
115
+ File.touch(controlfile) # Enter phase 3
116
+
117
+ # The real thing
118
+
119
+ if block_given?
120
+ if mode.nil?
121
+ res = yield
122
+ else
123
+ File.open(file, mode) do |f|
124
+ res = yield(f)
125
+ end
126
+ end
127
+ end
128
+
129
+ # Cleanup
130
+
131
+ File.delete(backupfile) # Enter phase 4
132
+ File.delete(controlfile) # Enter phase 5
133
+
134
+ # Return, like File.open
135
+
136
+ res = File.open(file, (mode or "r")) unless block_given?
137
+
138
+ res
139
+ end
140
+
141
+ def self.touch(file)
142
+ File.open(file, "a"){|f|}
143
+ end
144
+
145
+ def self.which(file)
146
+ res = nil
147
+
148
+ if windows?
149
+ file = file.gsub(/\.exe$/i, "") + ".exe"
150
+ sep = ";"
151
+ else
152
+ sep = ":"
153
+ end
154
+
155
+ catch :stop do
156
+ ENV["PATH"].split(/#{sep}/).reverse.each do |d|
157
+ if File.directory?(d)
158
+ Dir.new(d).each do |e|
159
+ if e.downcase == file.downcase
160
+ res = File.expand_path(e, d)
161
+ throw :stop
162
+ end
163
+ end
164
+ end
165
+ end
166
+ end
167
+
168
+ res
169
+ end
170
+ end