-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
702 lines (648 loc) · 20.5 KB
/
Copy pathmain.go
File metadata and controls
702 lines (648 loc) · 20.5 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
package main
import (
"flag"
"fmt"
"math/rand"
"os"
"github.com/jeromelesaux/dsk/cli/action"
"github.com/jeromelesaux/dsk/cli/msg"
"github.com/jeromelesaux/dsk/utils"
)
var (
help = flag.Bool("help", false, "Display extended help.")
list = flag.Bool("list", false, "List the contents of a DSK file.")
track = flag.Int("track", 39, "Track number (for formatting).")
heads = flag.Int("head", 1, "Number of heads in the DSK (format)")
sector = flag.Int("sector", 9, "Number of sectors (format).")
format = flag.Bool("format", false, "Format the specified DSK or SNA file.")
dskType = flag.Int("dsktype", 0, "DSK Type: 0 = DSK, 1 = EDSK, 3 = SNA.")
dskPath = flag.String("dsk", "", "Path to the DSK file to handle.")
hexa = flag.String("hex", "", "\tDisplay an AMSDOS file in hexadecimal format.")
info = flag.String("info", "", "Retrieve information about an AMSDOS file (size, execution, and loading address) or an SNA file.")
ascii = flag.String("ascii", "", "Display an AMSDOS file in ASCII format.")
disassemble = flag.String("disassemble", "", "Disassemble an AMSDOS file.")
get = flag.String("get", "", "\tExtract a file from the DSK file.")
remove = flag.String("remove", "", "Remove the AMSDOS file from the DSK file.")
basic = flag.String("basic", "", "Display a basic AMSDOS file.")
put = flag.String("put", "", "\tInsert the AMSDOS file into the DSK file.")
executeAddress = flag.String("exec", "", "Execution address for the inserted file (hexadecimal format, e.g., #170 allowed).")
loadingAddress = flag.String("load", "", "Loading address for the inserted file (hexadecimal format, e.g., #170 allowed).")
user = flag.Int("user", 0, "User number for the inserted file.")
force = flag.Bool("force", false, "Force overwrite of an existing file in the DSK.")
//fileType = flag.String("type", "", "Type of the inserted file: 'ascii' or 'binary'.")
snaPath = flag.String("sna", "", "\tPath to the SNA file to handle.")
analyse = flag.Bool("analyze", false, "Analyze and display the DSK header.")
cpcType = flag.Int("cpctype", 2, "CPC type for SNA import: 0 = CPC464, 1 = CPC664, 2 = CPC6128, 3 = Unknown, 4 = CPCPlus6128, 5 = CPCPlus464, 6 = GX4000.")
screenMode = flag.Int("screenmode", 1, "Screen mode parameter for SNA files.")
vendorFormat = flag.Bool("vendor", false, "Use vendor format for formatting (sector count = #09, last track = #27).")
dataFormat = flag.Bool("data", true, "Use data format for formatting (sector count = #09, last track = #27).")
rawimport = flag.Bool("rawimport", false, "Perform a raw import of an AMSDOS file. Requires '-dsk', '-track', and '-sector' options. \n\t\tCopies the file directly starting from the specified track and sector. e.g.: dsk -dsk mydskfile.dsk -put file.bin -rawimport -track 1 -sector 0")
rawexport = flag.Bool("rawexport", false, "Perform a raw export of an AMSDOS file. Requires '-dsk', '-track', '-sector', and '-size' options. \n\t\tExtracts the file content from the specified track and sector up to the given size. e.g.: dsk -dsk mydskfile.dsk -get file.bin -rawexport -track 1 -sector 0 -size 16384")
size = flag.Int("size", 0, "Size of data to extract for 'rawexport'. See 'rawexport' for details.")
autotest = flag.Bool("autotest", false, "Run all available tests.")
autoextract = flag.String("autoextract", "", "Extract all DSK files from a specified folder.")
snaVersion = flag.Int("snaversion", 1, "Specify the SNA version (1 or 2 available).")
quiet = flag.Bool("quiet", false, "Suppress unnecessary output (useful for scripting).")
stdoutOpt = flag.Bool("stdout", false, "To redirect to stdout when using get file")
hidden = flag.Bool("hide", false, "Hide the imported file")
removeHeader = flag.Bool("removeheader", false, "Remove amsdos header from exported file")
hfeFilepath = flag.String("hfe", "", "Path to the HFE file to handle.")
toDsk = flag.String("todsk", "", "Convert the specified HFE file to DSK format.")
toHfe = flag.String("tohfe", "", "Convert the specified DSK file to HFE format.")
appVersion = "0.37"
version = flag.Bool("version", false, "Display the application version and exit.")
)
func main() {
var cmdRunned bool
flag.Usage = sampleUsage
flag.Parse()
fd := action.NewAmsdosFileDescriptor().
WithUser(uint16(*user)).
AddExec(*executeAddress).
AddLoad(*loadingAddress).
WithAddHeader(*executeAddress != "" || *loadingAddress != "").
WithPaths(*put, *get, *basic, *hexa, *disassemble, *ascii, *remove, *info)
opts := action.NewOptions().
WithQuiet(*quiet).
WithFormat(*format).
WithForce(*force).
WithAnalyze(*analyse).
WithDataFormat(*dataFormat).
WithVendorFormat(*vendorFormat).
WithStdout(*stdoutOpt).
WithHidden(*hidden).
WithRemoveHeader(*removeHeader).
WithRawImport(*rawimport).
WithRawExport(*rawexport)
acts := action.NewDskTasks().
WithActionListDsk(*dskPath, true).
WithActionFormatDsk(*dskPath, *format).
WithActionDisplayHexaFileDsk(*dskPath, *hexa != "").
WithActionDesassembleFileDsk(*dskPath, *disassemble != "").
WithActionListBasic(*dskPath, *basic != "").
WithActionAnalyseDsk(*dskPath, *analyse).
WithActionPutFileDsk(*dskPath, *put != "").
WithActionRemoveFileDsk(*dskPath, *remove != "").
WithActionGetFileDsk(*dskPath, *get != "").
WithActionAsciiFileDsk(*dskPath, *ascii != "").
WithActionRawExportDsk(*dskPath, *rawexport).
WithActionRawImportDsk(*dskPath, *rawimport).
WithActionFileinfoDsk(*dskPath, *info != "").
WithActionGetAllFileDsk(*autoextract, *autoextract != "").
WithActionHFEFile(*hfeFilepath, *hfeFilepath != "").
WithActionConvertHFEToDSK(*toDsk, *toDsk != "").
WithActionConvertDSKToHFE(*toHfe, *toHfe != "")
desc := action.NewDskDescriptor().
WithSector(*sector).
WithTrack(*track).
WithHead(*heads).
WithType(*dskType)
dskAct := action.NewAction(*dskPath, *autoextract).
WithOptions(*opts).
WithAmsdosFileDescriptor(*fd).
WithDskDescriptor(*desc).
WithDskActions(acts)
snaAct := action.NewSnaAction(*snaPath).
WithCPCType(*cpcType).
WithScreemode(*screenMode).
WithVersion(*snaVersion).
WithSnaFormatAction(*format).
WithSnaInfoAction(*info != "").
WithSnaGetAction(*get != "").
WithSnaPutAction(*put != "").
WithSnaHexaListAction(*hexa != "").
WithFiles(*get, *put)
if *help || len(flag.Args()) == 1 {
sampleUsage()
os.Exit(0)
}
if *version {
fmt.Printf("%s", appVersion)
os.Exit(0)
}
if *autotest {
autotests()
os.Exit(0)
}
if !*quiet {
fmt.Fprintf(os.Stderr, "DSK cli version [%s]\nMade by Sid (ImpAct)\n", appVersion)
}
if snaAct.SnaIsSet() {
onErr, message, hint := snaAct.DoSnaActions()
if onErr {
msg.ExitOnError(message, hint)
}
os.Exit(0)
}
if dskAct.DskIsSet() {
onErr, message, hint := dskAct.DoDskActions()
if onErr {
msg.ExitOnError(message, hint)
}
os.Exit(0)
}
onErr, message, hint := dskAct.DoFileActions()
if onErr {
msg.ExitOnError(message, hint)
}
os.Exit(0)
if !cmdRunned {
sampleUsage()
}
os.Exit(0)
}
func sampleUsage() {
fmt.Fprintf(os.Stderr, "\nHere are some sample usages:\n"+
//" dsk -dsk input.dsk -toHfe output.hfe # Convert a DSK file to HFE format.\n"+
" dsk -hfe input.hfe -toDsk output.dsk # Convert an HFE file to DSK format.\n"+
" dsk -dsk output.dsk -format # Create an empty simple DSK file.\n"+
" dsk -dsk output.dsk -format -sector 8 -track 42 # Create a simple empty DSK file with custom tracks and sectors.\n"+
" dsk -dsk output.dsk -format -sector 8 -track 42 -dsktype 1 -head 2 # Create an empty extended DSK file with custom heads, tracks, and sectors.\n"+
" dsk -sna output.sna # Create an empty SNA file.\n"+
" dsk -info hello.bin # Display header informations on the file hello.bin"+
" dsk -dsk output.dsk -list # List the contents of the DSK file.\n"+
" dsk -sna output.sna -info # Get information about the SNA file.\n"+
" dsk -dsk output.dsk -info hello.bin # Get information about a file in the DSK.\n"+
" dsk -dsk output.dsk -hex hello.bin # Display the file content in hexadecimal format from the DSK file.\n"+
" dsk -dsk output.dsk -put hello.bin -exec \"#1000\" -load \"500\" # Insert a file into the DSK file.\n"+
" dsk -sna output.sna -put hello.bin -exec \"#1000\" -load 500 -screenmode 0 -cpctype 4 # Insert a file into the SNA file (for a CPC Plus system).\n\n")
fmt.Printf(("Options:\n"))
flag.VisitAll(func(f *flag.Flag) {
fmt.Printf(" -%s \t%s (default: %q)\n", f.Name, f.Usage, f.DefValue)
})
}
/*************************/
/* auto tests functions */
/*************************/
func autotests() {
var testsOnError int
var testsDone int
testsDone++
if parsing16bitsCAnnotation() {
fmt.Printf("OK\n")
} else {
fmt.Printf("OK\n")
testsOnError++
}
testsDone++
if parsing16bitsRasmAnnotation() {
fmt.Printf("OK\n")
} else {
fmt.Printf("OK\n")
testsOnError++
}
testsDone++
if parsing8bitsRasmAnnotation() {
fmt.Printf("OK\n")
} else {
fmt.Printf("OK\n")
testsOnError++
}
testsDone++
if parsing16bitsIntegerAnnotation() {
fmt.Printf("OK\n")
} else {
fmt.Printf("OK\n")
testsOnError++
}
dskpath := "vendor-format.dsk"
os.Remove(dskpath)
testsDone++
if formatVendorTest(dskpath) {
fmt.Printf("KO\n")
testsOnError++
} else {
fmt.Printf("OK\n")
}
testsDone++
if formatVendorForceTest(dskpath) {
fmt.Printf("KO\n")
testsOnError++
} else {
fmt.Printf("OK\n")
}
testsDone++
if listVendorTest(dskpath) {
fmt.Printf("KO\n")
testsOnError++
} else {
fmt.Printf("OK\n")
}
os.Remove(dskpath)
dskpath = "data-format-double.dsk"
testsDone++
if formatDoubleHeadDataTest(dskpath) {
fmt.Printf("KO\n")
testsOnError++
} else {
fmt.Printf("OK\n")
}
os.Remove(dskpath)
dskpath = "data-format.dsk"
testsDone++
if formatDataTest(dskpath) {
fmt.Printf("KO\n")
testsOnError++
} else {
fmt.Printf("OK\n")
}
testsDone++
if formatDataForceTest(dskpath) {
fmt.Printf("KO\n")
testsOnError++
} else {
fmt.Printf("OK\n")
}
testsDone++
if listDataTest(dskpath) {
fmt.Printf("KO\n")
testsOnError++
} else {
fmt.Printf("OK\n")
}
testsDone++
if analyseDataTest(dskpath) {
fmt.Printf("KO\n")
testsOnError++
} else {
fmt.Printf("OK\n")
}
testsDone++
if utils.SaveFile(generateSliceByte(512), "test.bin") {
fmt.Printf("KO\n")
testsOnError++
} else {
fmt.Printf("OK\n")
}
testsDone++
if putFileBinaryDataTest("test.bin", dskpath, false) {
fmt.Printf("KO\n")
testsOnError++
} else {
fmt.Printf("OK\n")
}
testsDone++
if err := os.Rename("test.bin", "test2.bin"); err != nil {
testsOnError++
}
testsDone++
if getFileBinaryDataTest("test.bin", dskpath) {
fmt.Printf("KO\n")
testsOnError++
} else {
fmt.Printf("OK\n")
}
testsDone++
if utils.SaveFile(generateSliceByte(2048), "test3.bin") {
fmt.Printf("KO\n")
testsOnError++
} else {
fmt.Printf("OK\n")
}
testsDone++
if putFileBinaryDataTest("test3.bin", dskpath, *hidden) {
fmt.Printf("KO\n")
testsOnError++
} else {
fmt.Printf("OK\n")
}
testsDone++
if err := os.Rename("test3.bin", "test4.bin"); err != nil {
testsOnError++
}
testsDone++
if getFileBinaryDataTest("test3.bin", dskpath) {
fmt.Printf("KO\n")
testsOnError++
} else {
fmt.Printf("OK\n")
}
testsDone++
if asciiFileBinaryDataTest("test3.bin", dskpath) {
fmt.Printf("KO\n")
testsOnError++
} else {
fmt.Printf("OK\n")
}
testsDone++
if desassembleFileBinaryDataTest("test3.bin", dskpath) {
fmt.Printf("KO\n")
testsOnError++
} else {
fmt.Printf("OK\n")
}
testsDone++
if hexaFileBinaryDataTest("test3.bin", dskpath) {
fmt.Printf("KO\n")
testsOnError++
} else {
fmt.Printf("OK\n")
}
testsDone++
if rawImportFileBinaryDataTest("test3.bin", dskpath) {
fmt.Printf("KO\n")
testsOnError++
} else {
fmt.Printf("OK\n")
}
testsDone++
if rawExportFileBinaryDataTest("test3.bin", dskpath, 2048) {
fmt.Printf("KO\n")
testsOnError++
} else {
fmt.Printf("OK\n")
}
testsDone++
if removeFileBinaryDataTest("test3.bin", dskpath) {
fmt.Printf("KO\n")
testsOnError++
} else {
fmt.Printf("OK\n")
}
testsDone++
os.Remove("test.bin")
testsDone++
os.Remove("test2.bin")
testsDone++
os.Remove("test3.bin")
testsDone++
os.Remove("test4.bin")
testsDone++
os.Remove(dskpath)
snapath := "test.sna"
testsDone++
if formatSnaTest(snapath) {
fmt.Printf("KO\n")
testsOnError++
} else {
fmt.Printf("OK\n")
}
testsDone++
if infoSnaTest(snapath) {
fmt.Printf("KO\n")
testsOnError++
} else {
fmt.Printf("OK\n")
}
testsDone++
os.Remove(snapath)
fmt.Printf("Tests done [%d] on failure [%d]\n", testsDone, testsOnError)
}
func resetArguments() {
*help = false
*list = false
*track = 39
*heads = 1
*sector = 9
*format = false
*dskType = 0
*dskPath = ""
*hexa = ""
*info = ""
*ascii = ""
*disassemble = ""
*get = ""
*remove = ""
*basic = ""
*put = ""
*executeAddress = ""
*loadingAddress = ""
*user = 0
*force = false
*snaPath = ""
*analyse = false
*cpcType = 2
*screenMode = 1
*vendorFormat = false
*dataFormat = true
*rawimport = false
*rawexport = false
*size = 0
*autotest = false
}
func generateSliceByte(size int) []byte {
b := make([]byte, size)
for i := 0; i < size; i++ {
v := rand.Intn(255 - 0)
b[i] = byte(v)
}
return b
}
func formatVendorTest(dskFilepath string) bool {
resetArguments()
fmt.Printf("Format vendor format ")
*format = true
sector := *sector
track := *track
heads := *heads
onError, _, _ := action.FormatDsk(dskFilepath, action.DskDescriptor{Path: dskFilepath, Sector: sector, Track: track, Head: heads}, true, false, false)
return onError
}
func formatVendorForceTest(dskFilepath string) bool {
resetArguments()
fmt.Printf("Format vendor format force option ")
*format = true
sector := *sector
track := *track
heads := *heads
*force = true
onError, _, _ := action.FormatDsk(dskFilepath, action.DskDescriptor{Path: dskFilepath, Sector: sector, Track: track, Head: heads}, true, false, true)
return onError
}
func formatDoubleHeadDataTest(dskFilepath string) bool {
resetArguments()
fmt.Printf("Format data format ")
*format = true
sector := *sector
track := *track
heads := 2
dskType := *dskType
onError, _, _ := action.FormatDsk(dskFilepath, action.DskDescriptor{Path: dskFilepath, Sector: sector, Track: track, Head: heads, Type: dskType}, false, true, false)
return onError
}
func formatDataTest(dskFilepath string) bool {
resetArguments()
fmt.Printf("Format data format ")
*format = true
sector := *sector
track := *track
heads := *heads
dskType := *dskType
onError, _, _ := action.FormatDsk(dskFilepath, action.DskDescriptor{Path: dskFilepath, Sector: sector, Track: track, Head: heads, Type: dskType}, false, true, false)
return onError
}
func formatDataForceTest(dskFilepath string) bool {
resetArguments()
fmt.Printf("Format data format force option")
*format = true
*force = true
sector := *sector
track := *track
heads := *heads
dskType := *dskType
onError, _, _ := action.FormatDsk(dskFilepath, action.DskDescriptor{Path: dskFilepath, Sector: sector, Track: track, Head: heads, Type: dskType}, false, true, true)
return onError
}
func formatSnaTest(snafilepath string) bool {
resetArguments()
fmt.Printf("Format sna image file ")
onError, _, _ := action.FormatSna(snafilepath, 2)
return onError
}
func infoSnaTest(snafilepath string) bool {
resetArguments()
fmt.Printf("Get information from sna image file ")
*info = snafilepath
onError, _, _ := action.InfoSna(snafilepath)
return onError
}
func listVendorTest(dskFilepath string) bool {
resetArguments()
fmt.Printf("list vendor format ")
*vendorFormat = true
*format = true
d, onError, _, _ := action.OpenDsk(dskFilepath, action.DskDescriptor{Path: dskFilepath, Sector: *sector, Track: *track, Head: *heads}, *quiet)
if onError {
return onError
}
onError, _, _ = action.ListDsk(d, dskFilepath)
return onError
}
func listDataTest(dskFilepath string) bool {
resetArguments()
fmt.Printf("list vendor format ")
*format = true
d, onError, _, _ := action.OpenDsk(dskFilepath, action.DskDescriptor{Path: dskFilepath, Sector: *sector, Track: *track, Head: *heads}, *quiet)
if onError {
return onError
}
onError, _, _ = action.ListDsk(d, dskFilepath)
return onError
}
func analyseDataTest(dskFilepath string) bool {
resetArguments()
fmt.Printf("list vendor format ")
*analyse = true
d, onError, _, _ := action.OpenDsk(dskFilepath, action.DskDescriptor{Path: dskFilepath, Sector: *sector, Track: *track, Head: *heads}, *quiet)
if onError {
return onError
}
onError, _, _ = action.AnalyseDsk(d, dskFilepath)
return onError
}
func parsing16bitsRasmAnnotation() bool {
fmt.Printf("Parsing value rasm annotation #C000 ")
v, err := utils.ParseHex16("#C000")
if err != nil {
return false
}
return v == 0xC000
}
func parsing16bitsCAnnotation() bool {
fmt.Printf("Parsing value c annotation 0xC000 ")
v, err := utils.ParseHex16("0xC000")
if err != nil {
return false
}
return v == 0xC000
}
func parsing16bitsIntegerAnnotation() bool {
fmt.Printf("Parsing value integer annotation 49152 ")
v, err := utils.ParseHex16("49152")
if err != nil {
return false
}
return v == 0xC000
}
func parsing8bitsRasmAnnotation() bool {
fmt.Printf("Parsing value c annotation #D0 ")
v, err := utils.ParseHex16("#D0")
if err != nil {
return false
}
return v == 0xD0
}
func putFileBinaryDataTest(filePath, dskFilepath string, hide bool) bool {
*put = dskFilepath
d, onError, _, _ := action.OpenDsk(dskFilepath, action.DskDescriptor{Path: dskFilepath, Sector: *sector, Track: *track, Head: *heads}, *quiet)
if onError {
return onError
}
fd := action.AmsdosFileDescriptor{
Path: filePath,
Exec: 0x800,
Load: 0x800,
User: uint16(*user),
Type: action.AmsdosTypeBinary,
}
isError, _, _ := action.PutFileDsk(d, dskFilepath, fd, hide, false, *quiet)
return isError
}
func getFileBinaryDataTest(filePath, dskFilepath string) bool {
*get = dskFilepath
// fileType := "binary"
d, onError, _, _ := action.OpenDsk(dskFilepath, action.DskDescriptor{Path: dskFilepath, Sector: *sector, Track: *track, Head: *heads}, *quiet)
if onError {
return onError
}
isError, _, _ := action.GetFileDsk(d, filePath, dskFilepath, "", false, *quiet)
return isError
}
func removeFileBinaryDataTest(fileInDsk, dskFilepath string) bool {
*remove = fileInDsk
d, onError, _, _ := action.OpenDsk(dskFilepath, action.DskDescriptor{Path: dskFilepath, Sector: *sector, Track: *track, Head: *heads}, *quiet)
if onError {
return onError
}
isError, _, _ := action.RemoveFileDsk(d, dskFilepath, fileInDsk)
return isError
}
func asciiFileBinaryDataTest(fileInDsk, dskFilepath string) bool {
*ascii = fileInDsk
d, onError, _, _ := action.OpenDsk(dskFilepath, action.DskDescriptor{Path: dskFilepath, Sector: *sector, Track: *track, Head: *heads}, *quiet)
if onError {
return onError
}
isError, _, _ := action.AsciiFileDsk(d, fileInDsk, false)
return isError
}
func desassembleFileBinaryDataTest(fileInDsk, dskFilepath string) bool {
*disassemble = fileInDsk
d, onError, _, _ := action.OpenDsk(dskFilepath, action.DskDescriptor{Path: dskFilepath, Sector: *sector, Track: *track, Head: *heads}, *quiet)
if onError {
return onError
}
isError, _, _ := action.DesassembleFileDsk(d, fileInDsk)
return isError
}
func hexaFileBinaryDataTest(fileInDsk, dskFilepath string) bool {
*hexa = fileInDsk
d, onError, _, _ := action.OpenDsk(dskFilepath, action.DskDescriptor{Path: dskFilepath, Sector: *sector, Track: *track, Head: *heads}, *quiet)
if onError {
return onError
}
isError, _, _ := action.DisplayHexaFileDsk(d, fileInDsk)
return isError
}
func rawImportFileBinaryDataTest(filePath, dskFilepath string) bool {
*rawimport = true
sector := 0
track := 1
d, onError, _, _ := action.OpenDsk(dskFilepath, action.DskDescriptor{Path: dskFilepath, Sector: sector, Track: track, Head: *heads}, *quiet)
if onError {
return onError
}
isError, _, _ := action.RawImportDsk(d, filePath, action.DskDescriptor{Path: dskFilepath, Sector: sector, Track: track, Head: *heads}, *quiet)
return isError
}
func rawExportFileBinaryDataTest(filePath, dskFilepath string, length int) bool {
*rawexport = true
sector := 0
track := 1
d, onError, _, _ := action.OpenDsk(dskFilepath, action.DskDescriptor{Path: dskFilepath, Sector: sector, Track: track, Head: *heads}, *quiet)
if onError {
return onError
}
isError, _, _ := action.RawExportDsk(d, filePath, action.DskDescriptor{Path: dskFilepath, Sector: sector, Track: track, Head: *heads}, length, *quiet)
return isError
}