blob: 535fe9f233e9a456ffc4928e34033a6ce7f69185 (
plain)
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
|
// SPDX-FileCopyrightText: 2026 Terin Stock <terinjokes@gmail.com>
// SPDX-License-Identifier: EUPL-1.2
package toolbox
import (
"strings"
)
const (
TOOLBOX_COUNT_CDS = 0xDA
TOOLBOX_LIST_CDS = 0xD7
TOOLBOX_SET_NEXT_CD = 0xD8
TOOLBOX_LIST_DEVICES = 0xD9
)
// FileType represents the type of file in a [FileEntry].
type FileType uint8
const (
File FileType = iota
Directory
)
// DeviceType represents the type of emulated device.
type DeviceType uint8
const (
Fixed DeviceType = iota
Removeable
Optical
Floppy14MB
MO
Sequential
Network
Zip100
None DeviceType = 0xFF
)
// FileEntry describes each file recognized by the ODE as
// emulatable media.
type FileEntry [40]byte
// Index is the file's index, to be used with [Device.SetCDByIndex].
func (e *FileEntry) Index() int {
return int(e[0])
}
// FileType returns the entry's file type.
func (e *FileEntry) FileType() FileType {
return FileType(e[1])
}
// Name is the entry's name, truncated to 32 characters.
func (e *FileEntry) Name() string {
str := string(e[2:35])
idx := strings.IndexByte(str, 0)
if idx < 0 {
idx = 33
}
return str[:idx]
}
// Size returns the size of the entry in bytes.
func (e *FileEntry) Size() uint64 {
return uint64(e[36])<<24 | uint64(e[37])<<16 | uint64(e[38])<<8 | uint64(e[39])
}
|