dsktool 0.1.4 → 0.1.5
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.
- data/bin/dskexplorer.rb +264 -0
- data/bin/dsktool.rb +34 -61
- data/doc/classes/AppleSoftFile.html +16 -16
- data/doc/classes/AppleSoftFile.src/M000020.html +18 -0
- data/doc/classes/AppleSoftFile.src/M000021.html +18 -0
- data/doc/classes/AppleSoftFile.src/M000022.html +18 -0
- data/doc/classes/AppleSoftFile.src/M000026.html +18 -0
- data/doc/classes/AppleSoftFile.src/M000027.html +18 -0
- data/doc/classes/AppleSoftFile.src/M000028.html +18 -0
- data/doc/classes/BinaryFile.html +16 -16
- data/doc/classes/BinaryFile.src/M000039.html +18 -0
- data/doc/classes/BinaryFile.src/M000040.html +18 -0
- data/doc/classes/BinaryFile.src/M000041.html +19 -0
- data/doc/classes/BinaryFile.src/M000045.html +18 -0
- data/doc/classes/BinaryFile.src/M000046.html +18 -0
- data/doc/classes/BinaryFile.src/M000047.html +19 -0
- data/doc/classes/CatalogServlet.html +146 -0
- data/doc/classes/CatalogServlet.src/M000015.html +20 -0
- data/doc/classes/CatalogServlet.src/M000021.html +20 -0
- data/doc/classes/D65.html +11 -11
- data/doc/classes/D65.src/M000018.html +18 -0
- data/doc/classes/D65.src/M000019.html +64 -0
- data/doc/classes/D65.src/M000024.html +18 -0
- data/doc/classes/D65.src/M000025.html +64 -0
- data/doc/classes/DOSDisk.html +16 -16
- data/doc/classes/DOSDisk.src/M000023.html +20 -0
- data/doc/classes/DOSDisk.src/M000024.html +19 -0
- data/doc/classes/DOSDisk.src/M000025.html +76 -0
- data/doc/classes/DOSDisk.src/M000029.html +20 -0
- data/doc/classes/DOSDisk.src/M000030.html +19 -0
- data/doc/classes/DOSDisk.src/M000031.html +76 -0
- data/doc/classes/DOSFile.html +32 -17
- data/doc/classes/DOSFile.src/M000042.html +22 -0
- data/doc/classes/DOSFile.src/M000043.html +18 -0
- data/doc/classes/DOSFile.src/M000044.html +18 -0
- data/doc/classes/DOSFile.src/M000048.html +22 -0
- data/doc/classes/DOSFile.src/M000049.html +18 -0
- data/doc/classes/DOSFile.src/M000050.html +18 -0
- data/doc/classes/DOSFile.src/M000051.html +31 -0
- data/doc/classes/DSK.html +54 -36
- data/doc/classes/DSK.src/M000027.html +18 -0
- data/doc/classes/DSK.src/M000028.html +22 -0
- data/doc/classes/DSK.src/M000029.html +22 -0
- data/doc/classes/DSK.src/M000030.html +34 -0
- data/doc/classes/DSK.src/M000031.html +19 -0
- data/doc/classes/DSK.src/M000032.html +18 -0
- data/doc/classes/DSK.src/M000033.html +18 -0
- data/doc/classes/DSK.src/M000034.html +22 -0
- data/doc/classes/DSK.src/M000035.html +22 -0
- data/doc/classes/DSK.src/M000036.html +34 -0
- data/doc/classes/DSK.src/M000037.html +19 -0
- data/doc/classes/DSK.src/M000038.html +18 -0
- data/doc/classes/DSK.src/M000039.html +40 -0
- data/doc/classes/DSK.src/M000040.html +23 -0
- data/doc/classes/DirectoryServlet.html +146 -0
- data/doc/classes/DirectoryServlet.src/M000017.html +20 -0
- data/doc/classes/DirectoryServlet.src/M000023.html +20 -0
- data/doc/classes/IntegerBasicFile.html +16 -16
- data/doc/classes/IntegerBasicFile.src/M000012.html +18 -0
- data/doc/classes/IntegerBasicFile.src/M000013.html +18 -0
- data/doc/classes/IntegerBasicFile.src/M000014.html +18 -0
- data/doc/classes/IntegerBasicFile.src/M000018.html +18 -0
- data/doc/classes/IntegerBasicFile.src/M000019.html +18 -0
- data/doc/classes/IntegerBasicFile.src/M000020.html +18 -0
- data/doc/classes/RDoc.html +6 -6
- data/doc/classes/RDoc.src/M000048.html +40 -0
- data/doc/classes/RDoc.src/M000055.html +40 -0
- data/doc/classes/SCAsmFile.html +21 -21
- data/doc/classes/SCAsmFile.src/M000035.html +18 -0
- data/doc/classes/SCAsmFile.src/M000036.html +18 -0
- data/doc/classes/SCAsmFile.src/M000037.html +18 -0
- data/doc/classes/SCAsmFile.src/M000038.html +36 -0
- data/doc/classes/SCAsmFile.src/M000041.html +18 -0
- data/doc/classes/SCAsmFile.src/M000042.html +18 -0
- data/doc/classes/SCAsmFile.src/M000043.html +18 -0
- data/doc/classes/SCAsmFile.src/M000044.html +36 -0
- data/doc/classes/ShowFileServlet.html +146 -0
- data/doc/classes/ShowFileServlet.src/M000026.html +21 -0
- data/doc/classes/ShowFileServlet.src/M000032.html +22 -0
- data/doc/classes/TestDOSDisks.html +41 -26
- data/doc/classes/TestDOSDisks.src/M000006.html +24 -0
- data/doc/classes/TestDOSDisks.src/M000007.html +19 -0
- data/doc/classes/TestDOSDisks.src/M000008.html +19 -0
- data/doc/classes/TestDOSDisks.src/M000009.html +25 -0
- data/doc/classes/TestDOSDisks.src/M000010.html +41 -0
- data/doc/classes/TestDOSDisks.src/M000011.html +27 -0
- data/doc/classes/TestDOSDisks.src/M000012.html +24 -0
- data/doc/classes/TestDOSDisks.src/M000013.html +19 -0
- data/doc/classes/TestDOSDisks.src/M000014.html +19 -0
- data/doc/classes/TestDOSDisks.src/M000015.html +25 -0
- data/doc/classes/TestDOSDisks.src/M000016.html +41 -0
- data/doc/classes/TestDOSDisks.src/M000017.html +27 -0
- data/doc/classes/TestDisassembly.html +6 -6
- data/doc/classes/TestDisassembly.src/M000016.html +19 -0
- data/doc/classes/TestDisassembly.src/M000022.html +19 -0
- data/doc/classes/TextFile.html +16 -16
- data/doc/classes/TextFile.src/M000045.html +18 -0
- data/doc/classes/TextFile.src/M000046.html +18 -0
- data/doc/classes/TextFile.src/M000047.html +20 -0
- data/doc/classes/TextFile.src/M000052.html +18 -0
- data/doc/classes/TextFile.src/M000053.html +18 -0
- data/doc/classes/TextFile.src/M000054.html +20 -0
- data/doc/created.rid +1 -1
- data/doc/dot/f_0.dot +44 -16
- data/doc/dot/f_0.png +0 -0
- data/doc/dot/f_1.dot +1 -10
- data/doc/dot/f_1.png +0 -0
- data/doc/dot/f_2.dot +4 -13
- data/doc/dot/f_2.png +0 -0
- data/doc/dot/f_3.dot +8 -64
- data/doc/dot/f_3.png +0 -0
- data/doc/dot/f_4.dot +69 -4
- data/doc/dot/f_4.png +0 -0
- data/doc/dot/f_5.dot +4 -13
- data/doc/dot/f_5.png +0 -0
- data/doc/dot/f_6.dot +15 -17
- data/doc/dot/f_6.png +0 -0
- data/doc/dot/f_7.dot +19 -1
- data/doc/dot/f_7.png +0 -0
- data/doc/dot/f_8.dot +32 -0
- data/doc/dot/f_8.png +0 -0
- data/doc/dot/f_9.dot +14 -0
- data/doc/dot/f_9.png +0 -0
- data/doc/dot/m_6_0.dot +30 -0
- data/doc/dot/m_6_0.png +0 -0
- data/doc/files/bin/dskexplorer_rb.html +339 -0
- data/doc/files/bin/dskexplorer_rb.src/M000001.html +21 -0
- data/doc/files/bin/dskexplorer_rb.src/M000002.html +21 -0
- data/doc/files/bin/dskexplorer_rb.src/M000003.html +22 -0
- data/doc/files/bin/dskexplorer_rb.src/M000004.html +19 -0
- data/doc/files/bin/dskexplorer_rb.src/M000005.html +20 -0
- data/doc/files/bin/dskexplorer_rb.src/M000006.html +22 -0
- data/doc/files/bin/dskexplorer_rb.src/M000007.html +20 -0
- data/doc/files/bin/dskexplorer_rb.src/M000008.html +43 -0
- data/doc/files/bin/dskexplorer_rb.src/M000009.html +55 -0
- data/doc/files/bin/dskexplorer_rb.src/M000010.html +43 -0
- data/doc/files/bin/dskexplorer_rb.src/M000011.html +34 -0
- data/doc/files/bin/dskserver_rb.html +247 -0
- data/doc/files/bin/dskserver_rb.src/M000001.html +22 -0
- data/doc/files/bin/dskserver_rb.src/M000002.html +19 -0
- data/doc/files/bin/dskserver_rb.src/M000003.html +62 -0
- data/doc/files/bin/dskserver_rb.src/M000004.html +39 -0
- data/doc/files/bin/dskserver_rb.src/M000005.html +26 -0
- data/doc/files/bin/dsktool_rb.html +8 -5
- data/doc/files/lib/D65_rb.html +1 -1
- data/doc/files/lib/DOSDisk_rb.html +2 -2
- data/doc/files/lib/DOSFile_rb.html +2 -2
- data/doc/files/lib/DSK_rb.html +2 -2
- data/doc/files/lib/rdoc_patch_rb.html +114 -0
- data/doc/files/test/tc_disassembly_rb.html +1 -1
- data/doc/files/test/tc_dos_disks_rb.html +2 -2
- data/doc/files/test/ts_test_all_rb.html +1 -1
- data/doc/fr_class_index.html +3 -0
- data/doc/fr_file_index.html +2 -0
- data/doc/fr_method_index.html +55 -38
- data/doc/index.html +1 -1
- data/doc/rdoc-style.css +208 -0
- data/lib/DOSDisk.rb +2 -2
- data/lib/DOSFile.rb +21 -3
- data/lib/DSK.rb +6 -1
- data/lib/rdoc_patch.rb +32 -0
- data/test/tc_dos_disks.rb +13 -2
- data/test/white_11a.dsk +0 -0
- metadata +134 -4
data/bin/dskexplorer.rb
ADDED
@@ -0,0 +1,264 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
# dskserver.rb
|
3
|
+
#
|
4
|
+
# == Synopsis
|
5
|
+
# A web-based DSK file explorer
|
6
|
+
#
|
7
|
+
# == Usage
|
8
|
+
# dskserver.rb [switches]
|
9
|
+
#
|
10
|
+
# -h | --help display this message
|
11
|
+
# -p | --port PORT_NUMBER port number to listen on (default is 6052)
|
12
|
+
# -r | --root ROOT_DIR root directory to explore from (default is current directory)
|
13
|
+
# -v | --version show version number
|
14
|
+
|
15
|
+
#make sure the relevant folder with our libraries is in the require path
|
16
|
+
lib_path=File.expand_path(File.dirname(__FILE__)+"//..//lib")
|
17
|
+
$:.unshift(lib_path) unless $:.include?(lib_path)
|
18
|
+
|
19
|
+
require 'optparse'
|
20
|
+
require 'rdoc_patch' #RDoc::usage patched to work under gem executables
|
21
|
+
DSKSERVER_VERSION="0.1.0"
|
22
|
+
|
23
|
+
@listening_port=6502
|
24
|
+
@@root_directory="."
|
25
|
+
opts=OptionParser.new
|
26
|
+
opts.on("-h","--help") {RDoc::usage_from_file(__FILE__)}
|
27
|
+
opts.on("-v","--version") do
|
28
|
+
puts File.basename($0)+" "+DSKSERVER_VERSION
|
29
|
+
exit
|
30
|
+
end
|
31
|
+
opts.on("-p","--port PORT_NUMBER",Integer) {|val| @listening_port=val%0xFFFF}
|
32
|
+
opts.on("-r","--root ROOT_DIR",String) {|val| @@root_directory=val}
|
33
|
+
|
34
|
+
filename=opts.parse(ARGV)[0] rescue RDoc::usage_from_file(__FILE__,'Usage')
|
35
|
+
|
36
|
+
require 'webrick'
|
37
|
+
require 'DSK'
|
38
|
+
include WEBrick
|
39
|
+
|
40
|
+
@@uri_cache={}
|
41
|
+
@@dsk_cache={}
|
42
|
+
def get_uri_from_cache(uri)
|
43
|
+
if @@uri_cache[uri].nil? then
|
44
|
+
@@uri_cache[uri]=open(uri).read
|
45
|
+
end
|
46
|
+
@@uri_cache[uri]
|
47
|
+
end
|
48
|
+
|
49
|
+
def get_dsk_from_cache(uri)
|
50
|
+
if @@dsk_cache[uri].nil? then
|
51
|
+
@@dsk_cache[uri]=DSK.read(uri)
|
52
|
+
end
|
53
|
+
@@dsk_cache[uri]
|
54
|
+
end
|
55
|
+
|
56
|
+
def common_header
|
57
|
+
"
|
58
|
+
<html>
|
59
|
+
<body>
|
60
|
+
<B>DSK Explorer</b><br>
|
61
|
+
"
|
62
|
+
end
|
63
|
+
def common_footer
|
64
|
+
"
|
65
|
+
"
|
66
|
+
end
|
67
|
+
|
68
|
+
def root_dir_is_website?
|
69
|
+
require 'hpricot'
|
70
|
+
require 'open-uri'
|
71
|
+
@@root_directory=~/^http[s]?:/?true : false
|
72
|
+
end
|
73
|
+
def make_absolute_path(relative_path)
|
74
|
+
if root_dir_is_website? then
|
75
|
+
@@root_directory+uri_encode(relative_path)
|
76
|
+
else
|
77
|
+
@@root_directory+relative_path
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def uri_encode(s)
|
82
|
+
#standard URI.escape appears to miss some important characters
|
83
|
+
require 'uri'
|
84
|
+
URI.escape(s).sub("[","%5b").sub("]","%5d")
|
85
|
+
end
|
86
|
+
def get_directories_and_files(relative_path)
|
87
|
+
directories=[]
|
88
|
+
dsk_files=[]
|
89
|
+
absolute_path=make_absolute_path(relative_path)
|
90
|
+
if root_dir_is_website? then
|
91
|
+
html=get_uri_from_cache(absolute_path)
|
92
|
+
doc=Hpricot(html)
|
93
|
+
doc.search("a[@href]").each do |a|
|
94
|
+
href=URI.unescape(a.attributes["href"])
|
95
|
+
if (href=~/\w\/$/)
|
96
|
+
if !(href=~/^\//) then #directories end with a /, but skip absolute paths
|
97
|
+
directories<<(href)
|
98
|
+
end
|
99
|
+
elsif DSK.is_dsk_file?(href) then
|
100
|
+
dsk_files<<(href)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
else
|
104
|
+
if File.exist?(absolute_path) && (File.stat(absolute_path).directory?) then
|
105
|
+
dir=Dir.new(absolute_path)
|
106
|
+
dir.each do |f|
|
107
|
+
directories<<f if (f[0].chr!=".") && (File.stat(absolute_path+"/"+f).directory?)
|
108
|
+
dsk_files<<f if (DSK.is_dsk_file?(f))
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
[directories,dsk_files]
|
113
|
+
end
|
114
|
+
|
115
|
+
def make_navigation_path(relative_path,filename=nil)
|
116
|
+
path_parts=relative_path.split("/")
|
117
|
+
#make the cookie-crumb-trail
|
118
|
+
partial_path=""
|
119
|
+
s="<a href=/dir/>#{@@root_directory}</a>"
|
120
|
+
path_parts.each do |p|
|
121
|
+
if p.length>0 then
|
122
|
+
partial_path+="/#{p}"
|
123
|
+
if DSK.is_dsk_file?(partial_path) then
|
124
|
+
s+="/<a href=/catalog#{uri_encode(partial_path)}>#{p}</a>"
|
125
|
+
else
|
126
|
+
s+="/<a href=/dir#{uri_encode(partial_path)}>#{p}</a>"
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
if !filename.nil? then
|
132
|
+
s+="/<a href=/showfile/#{uri_encode(relative_path)+'?filename='+uri_encode(filename)}>#{filename}</a>"
|
133
|
+
end
|
134
|
+
|
135
|
+
|
136
|
+
#show the contents of the current directory
|
137
|
+
directories,dsk_files=get_directories_and_files(relative_path)
|
138
|
+
|
139
|
+
#list out the directories
|
140
|
+
|
141
|
+
s+="<ul>"
|
142
|
+
#s+="<li>[dir] <a href=/#{uri_encode('/dir/'+File.dirname(relative_path))}>..</a>\n"
|
143
|
+
directories.sort.each do |d|
|
144
|
+
s+="<li>[dir] <a href=/dir/#{uri_encode(relative_path)}/#{uri_encode(d)}>#{d}</a>\n"
|
145
|
+
end
|
146
|
+
|
147
|
+
#list out the DSK files
|
148
|
+
dsk_files.sort.each do |f|
|
149
|
+
s+="<li>[dsk] <a href=/catalog/#{uri_encode(relative_path)}/#{uri_encode(f)}>#{f}</a> [ <a href=#{uri_encode(@@root_directory+relative_path+'/'+f)}>download</a> ]\n"
|
150
|
+
end
|
151
|
+
s+="</ul>"
|
152
|
+
|
153
|
+
s
|
154
|
+
end
|
155
|
+
def make_catalog(relative_path)
|
156
|
+
s="<p>"
|
157
|
+
begin
|
158
|
+
absolute_path=make_absolute_path(relative_path)
|
159
|
+
dsk=get_dsk_from_cache(absolute_path)
|
160
|
+
if (dsk.is_dos33?) then
|
161
|
+
s+="<table>\n<th>TYPE</th><th>SECTORS</th><th>NAME</th></tr>\n"
|
162
|
+
dsk.files.each_value do |f|
|
163
|
+
display_url="/showfile/#{uri_encode(relative_path)+'?filename='+uri_encode(f.filename)}"
|
164
|
+
s+="<td>#{f.file_type}</td><td>#{sprintf('%03d',f.sector_count)}</td><td>#{f.filename}</td>"
|
165
|
+
s+="<td><a href=#{display_url}&mode=hex>hex dump</a></td>"
|
166
|
+
if f.file_type=="T" then
|
167
|
+
s+="<td><a href=#{display_url}&mode=text>text</a></td>"
|
168
|
+
else
|
169
|
+
s+="<td><a href=#{display_url}&mode=list>listing</a></td>"
|
170
|
+
end
|
171
|
+
|
172
|
+
s+="</tr>\n"
|
173
|
+
end
|
174
|
+
s+="</table>"
|
175
|
+
else
|
176
|
+
s+="<i>not DOS 3.3 format</i>"
|
177
|
+
end
|
178
|
+
rescue Exception => exception
|
179
|
+
s+="<i>ERROR:#{exception}</i>"
|
180
|
+
end
|
181
|
+
s
|
182
|
+
end
|
183
|
+
def show_file(relative_path,filename,display_mode)
|
184
|
+
absolute_path=make_absolute_path(relative_path)
|
185
|
+
dsk=get_dsk_from_cache(absolute_path)
|
186
|
+
file=dsk.files[filename]
|
187
|
+
if file.nil? then
|
188
|
+
s="<i>#{filename} not found</i>"
|
189
|
+
else
|
190
|
+
s="<hl><pre>"
|
191
|
+
if display_mode=="hex" then
|
192
|
+
s+=file.hex_dump
|
193
|
+
elsif display_mode=="list" && file.file_type=='B'
|
194
|
+
then s+=file.disassembly
|
195
|
+
else
|
196
|
+
s+= file.to_s
|
197
|
+
end
|
198
|
+
s+="\n</pre><hl>"
|
199
|
+
end
|
200
|
+
s
|
201
|
+
end
|
202
|
+
|
203
|
+
class DirectoryServlet < HTTPServlet::AbstractServlet
|
204
|
+
def do_GET(req,res)
|
205
|
+
relative_path=URI.unescape(req.path).sub(/^\/dir/,"")
|
206
|
+
res['Content-Type']="text/html"
|
207
|
+
res.body=common_header+make_navigation_path(relative_path)+common_footer
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
class CatalogServlet < HTTPServlet::AbstractServlet
|
212
|
+
def do_GET(req,res)
|
213
|
+
relative_path=URI.unescape(req.path).sub(/^\/catalog/,"")
|
214
|
+
res['Content-Type']="text/html"
|
215
|
+
res.body=common_header+make_navigation_path(relative_path)+make_catalog(relative_path)+common_footer
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
class ShowFileServlet < HTTPServlet::AbstractServlet
|
220
|
+
def do_GET(req,res)
|
221
|
+
relative_path=URI.unescape(req.path).sub(/^\/showfile/,"")
|
222
|
+
filename=URI.unescape(req.query['filename'])
|
223
|
+
display_mode=req.query['mode']
|
224
|
+
res['Content-Type']="text/html"
|
225
|
+
res.body=common_header+make_navigation_path(relative_path,filename)+show_file(relative_path,filename,display_mode)+common_footer
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
s=HTTPServer.new(
|
230
|
+
:Port=>@listening_port
|
231
|
+
)
|
232
|
+
trap("INT") {s.shutdown}
|
233
|
+
|
234
|
+
s.mount("/dir",DirectoryServlet)
|
235
|
+
s.mount("/catalog",CatalogServlet)
|
236
|
+
s.mount("/showfile",ShowFileServlet)
|
237
|
+
|
238
|
+
puts "point your browser at http://localhost:#{@listening_port}/"
|
239
|
+
s.start
|
240
|
+
|
241
|
+
# == Author
|
242
|
+
# Jonno Downes (jonno@jamtronix.com)
|
243
|
+
#
|
244
|
+
# == Copyright
|
245
|
+
# Copyright (c) 2007 Jonno Downes (jonno@jamtronix.com)
|
246
|
+
#
|
247
|
+
#Permission is hereby granted, free of charge, to any person obtaining
|
248
|
+
#a copy of this software and associated documentation files (the
|
249
|
+
#"Software"), to deal in the Software without restriction, including
|
250
|
+
#without limitation the rights to use, copy, modify, merge, publish,
|
251
|
+
#distribute, sublicense, and/or sell copies of the Software, and to
|
252
|
+
#permit persons to whom the Software is furnished to do so, subject to
|
253
|
+
#the following conditions:
|
254
|
+
#
|
255
|
+
# The above copyright notice and this permission notice shall be
|
256
|
+
# included in all copies or substantial portions of the Software.
|
257
|
+
#
|
258
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
259
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
260
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
261
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
262
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
263
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
264
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/bin/dsktool.rb
CHANGED
@@ -11,7 +11,8 @@
|
|
11
11
|
# -c | --catalog display catalog
|
12
12
|
# -e | --extract FILENAME extract file by name (either to stdout,
|
13
13
|
# or file specified by --output)
|
14
|
-
# -h | --help display this message
|
14
|
+
# -h | --help display this message
|
15
|
+
# -d | --dump FILENAME hex dump
|
15
16
|
# -l | --list FILENAME monitor style listing (disassembles 65C02 opcodes)
|
16
17
|
# -o | --output FILENAME specify name to save extracted file as
|
17
18
|
# -r | --raw don't convert basic files to ASCII
|
@@ -29,73 +30,51 @@
|
|
29
30
|
# dsktool.rb --extract "COLOR DEMOSOFT" DOS3MASTR.dsk
|
30
31
|
# dsktool.rb -e HELLO -o HELLO.bas DOS3MASTR.dsk
|
31
32
|
# dsktool.rb -x DOS3MASTR.dsk.gz
|
33
|
+
# dsktool.rb -x DOS3MASTR.dsk.gz -o /tmp/DOS3MASTR/
|
32
34
|
# dsktool.rb -c http://jamtronix.com/dsks/apshai.dsk.gz
|
33
35
|
|
34
|
-
DSKTOOL_VERSION="0.1.
|
36
|
+
DSKTOOL_VERSION="0.1.5"
|
35
37
|
|
36
|
-
require
|
37
|
-
|
38
|
-
|
39
|
-
#due to a bug in rdoc, RDoc.usage won't work correctly when run from a gem executable
|
40
|
-
# see http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/211297
|
41
|
-
# Display usage from the given file
|
42
|
-
def RDoc.usage_from_file(input_file, *args)
|
43
|
-
comment = File.open(input_file) do |file|
|
44
|
-
RDoc.find_comment(file)
|
45
|
-
end
|
46
|
-
comment = comment.gsub(/^\s*#/, '')
|
47
|
-
|
48
|
-
markup = SM::SimpleMarkup.new
|
49
|
-
flow_convertor = SM::ToFlow.new
|
50
|
-
|
51
|
-
flow = markup.convert(comment, flow_convertor)
|
52
|
-
|
53
|
-
format = "plain"
|
54
|
-
|
55
|
-
unless args.empty?
|
56
|
-
flow = extract_sections(flow, args)
|
57
|
-
end
|
58
|
-
|
59
|
-
options = RI::Options.instance
|
60
|
-
if args = ENV["RI"]
|
61
|
-
options.parse(args.split)
|
62
|
-
end
|
63
|
-
formatter = options.formatter.new(options, "")
|
64
|
-
formatter.display_flow(flow)
|
65
|
-
exit
|
66
|
-
end
|
38
|
+
#make sure the relevant folder with our libraries is in the require path
|
39
|
+
lib_path=File.expand_path(File.dirname(__FILE__)+"//..//lib")
|
40
|
+
$:.unshift(lib_path) unless $:.include?(lib_path)
|
67
41
|
|
42
|
+
require 'optparse'
|
43
|
+
require 'rdoc_patch' #RDoc::usage patched to work under gem executables
|
68
44
|
|
69
45
|
catalog=false
|
70
46
|
explode=false
|
71
|
-
raw_mode=false
|
72
47
|
output_filename=nil
|
73
48
|
extract_filename=nil
|
74
|
-
|
49
|
+
extract_mode=:default
|
75
50
|
explode_directory=nil
|
76
51
|
opts=OptionParser.new
|
77
52
|
opts.on("-h","--help") {RDoc::usage_from_file(__FILE__)}
|
78
53
|
opts.on("-v","--version") do
|
79
|
-
|
54
|
+
puts File.basename($0)+" "+DSKTOOL_VERSION
|
80
55
|
exit
|
81
56
|
end
|
82
|
-
opts.on("-r","--raw") {
|
57
|
+
opts.on("-r","--raw") {extract_mode=:raw}
|
83
58
|
opts.on("-c","--catalog") {catalog=true}
|
84
59
|
opts.on("-x","--explode") {explode=true}
|
85
|
-
opts.on("-l","--list FILENAME",String)
|
60
|
+
opts.on("-l","--list FILENAME",String) do |val|
|
61
|
+
extract_filename=val.upcase
|
62
|
+
extract_mode=:list
|
63
|
+
end
|
64
|
+
opts.on("-d","--dump FILENAME",String) do |val|
|
65
|
+
extract_filename=val.upcase
|
66
|
+
extract_mode=:hex
|
67
|
+
end
|
86
68
|
opts.on("-e","--extract FILENAME",String) {|val| extract_filename=val.upcase}
|
87
69
|
opts.on("-o","--output FILENAME",String) {|val| output_filename=val}
|
88
70
|
filename=opts.parse(ARGV)[0] rescue RDoc::usage_from_file(__FILE__,'Usage')
|
89
71
|
RDoc::usage_from_file(__FILE__,'Usage') if (filename.nil?)
|
90
72
|
|
91
|
-
#make sure the relevant folder with our libraries is in the require path
|
92
|
-
lib_path=File.expand_path(File.dirname(__FILE__)+"//..//lib")
|
93
|
-
$:.unshift(lib_path) unless $:.include?(lib_path)
|
94
73
|
|
95
74
|
require 'DSK'
|
96
75
|
dsk=DSK.read(filename)
|
97
76
|
output_file= case
|
98
|
-
when (output_filename.nil?) then STDOUT
|
77
|
+
when (output_filename.nil?) || (explode) then STDOUT
|
99
78
|
else File.open(output_filename,"wb")
|
100
79
|
end
|
101
80
|
|
@@ -108,7 +87,7 @@ if(catalog) then
|
|
108
87
|
end
|
109
88
|
|
110
89
|
if(explode) then
|
111
|
-
output_dir=File.basename(filename,".*")
|
90
|
+
output_dir=output_filename.nil??File.basename(filename,".*"):output_filename
|
112
91
|
if !(File.exists?(output_dir)) then
|
113
92
|
Dir.mkdir(output_dir)
|
114
93
|
end
|
@@ -129,24 +108,18 @@ if (!extract_filename.nil?) then
|
|
129
108
|
file=dsk.files[extract_filename]
|
130
109
|
if file.nil? then
|
131
110
|
puts "'#{extract_filename}' not found in #{filename}"
|
132
|
-
else
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
puts "'#{list_filename}' not found in #{filename}"
|
145
|
-
else
|
146
|
-
if file.instance_of?(BinaryFile)
|
147
|
-
output_file<<file.disassembly
|
148
|
-
else
|
149
|
-
puts "'#{list_filename}' is not a binary file"
|
111
|
+
else
|
112
|
+
output_file<< case extract_mode
|
113
|
+
when :raw then file.contents
|
114
|
+
when :hex then file.hex_dump
|
115
|
+
when :list then
|
116
|
+
if file.instance_of?(BinaryFile)
|
117
|
+
file.disassembly
|
118
|
+
else
|
119
|
+
puts "'#{extract_filename}' is not a binary file"
|
120
|
+
exit
|
121
|
+
end
|
122
|
+
else file.to_s
|
150
123
|
end
|
151
124
|
end
|
152
125
|
end
|
@@ -88,7 +88,7 @@
|
|
88
88
|
<area shape="RECT" coords="256,5,328,53" href="DOSFile.html" alt="DOSFile">
|
89
89
|
<area shape="RECT" coords="456,101,528,149" href="TextFile.html" alt="TextFile">
|
90
90
|
</map>
|
91
|
-
<img src="../dot/
|
91
|
+
<img src="../dot/f_4.png" usemap="#map" border=0 alt="TopLevel">
|
92
92
|
</div>
|
93
93
|
|
94
94
|
<div id="description">
|
@@ -119,9 +119,9 @@ Applesoft file format:
|
|
119
119
|
<h3 class="section-bar">Methods</h3>
|
120
120
|
|
121
121
|
<div class="name-list">
|
122
|
-
<a href="#
|
123
|
-
<a href="#
|
124
|
-
<a href="#
|
122
|
+
<a href="#M000028">file_extension</a>
|
123
|
+
<a href="#M000026">file_type</a>
|
124
|
+
<a href="#M000027">to_s</a>
|
125
125
|
</div>
|
126
126
|
</div>
|
127
127
|
|
@@ -156,12 +156,12 @@ Applesoft file format:
|
|
156
156
|
<div id="methods">
|
157
157
|
<h3 class="section-bar">Public Instance methods</h3>
|
158
158
|
|
159
|
-
<div id="method-
|
160
|
-
<a name="
|
159
|
+
<div id="method-M000028" class="method-detail">
|
160
|
+
<a name="M000028"></a>
|
161
161
|
|
162
162
|
<div class="method-heading">
|
163
|
-
<a href="AppleSoftFile.src/
|
164
|
-
onclick="popupCode('AppleSoftFile.src/
|
163
|
+
<a href="AppleSoftFile.src/M000028.html" target="Code" class="method-signature"
|
164
|
+
onclick="popupCode('AppleSoftFile.src/M000028.html');return false;">
|
165
165
|
<span class="method-name">file_extension</span><span class="method-args">()</span>
|
166
166
|
</a>
|
167
167
|
</div>
|
@@ -170,12 +170,12 @@ Applesoft file format:
|
|
170
170
|
</div>
|
171
171
|
</div>
|
172
172
|
|
173
|
-
<div id="method-
|
174
|
-
<a name="
|
173
|
+
<div id="method-M000026" class="method-detail">
|
174
|
+
<a name="M000026"></a>
|
175
175
|
|
176
176
|
<div class="method-heading">
|
177
|
-
<a href="AppleSoftFile.src/
|
178
|
-
onclick="popupCode('AppleSoftFile.src/
|
177
|
+
<a href="AppleSoftFile.src/M000026.html" target="Code" class="method-signature"
|
178
|
+
onclick="popupCode('AppleSoftFile.src/M000026.html');return false;">
|
179
179
|
<span class="method-name">file_type</span><span class="method-args">()</span>
|
180
180
|
</a>
|
181
181
|
</div>
|
@@ -184,12 +184,12 @@ Applesoft file format:
|
|
184
184
|
</div>
|
185
185
|
</div>
|
186
186
|
|
187
|
-
<div id="method-
|
188
|
-
<a name="
|
187
|
+
<div id="method-M000027" class="method-detail">
|
188
|
+
<a name="M000027"></a>
|
189
189
|
|
190
190
|
<div class="method-heading">
|
191
|
-
<a href="AppleSoftFile.src/
|
192
|
-
onclick="popupCode('AppleSoftFile.src/
|
191
|
+
<a href="AppleSoftFile.src/M000027.html" target="Code" class="method-signature"
|
192
|
+
onclick="popupCode('AppleSoftFile.src/M000027.html');return false;">
|
193
193
|
<span class="method-name">to_s</span><span class="method-args">()</span>
|
194
194
|
</a>
|
195
195
|
</div>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>file_type (AppleSoftFile)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/DOSFile.rb, line 272</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">file_type</span>
|
15
|
+
<span class="ruby-value str">"A"</span>
|
16
|
+
<span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>to_s (AppleSoftFile)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/DOSFile.rb, line 276</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>
|
15
|
+
<span class="ruby-identifier">buffer_as_applesoft_file</span>(<span class="ruby-ivar">@contents</span>)
|
16
|
+
<span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>file_extension (AppleSoftFile)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/DOSFile.rb, line 280</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">file_extension</span>
|
15
|
+
<span class="ruby-value str">".bas"</span>
|
16
|
+
<span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>file_type (AppleSoftFile)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/DOSFile.rb, line 289</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">file_type</span>
|
15
|
+
<span class="ruby-value str">"A"</span>
|
16
|
+
<span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>to_s (AppleSoftFile)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/DOSFile.rb, line 293</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>
|
15
|
+
<span class="ruby-identifier">buffer_as_applesoft_file</span>(<span class="ruby-ivar">@contents</span>)
|
16
|
+
<span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>file_extension (AppleSoftFile)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/DOSFile.rb, line 297</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">file_extension</span>
|
15
|
+
<span class="ruby-value str">".bas"</span>
|
16
|
+
<span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|