forked from kdomanski/iso9660
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrockridge.go
60 lines (50 loc) · 1.4 KB
/
rockridge.go
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
package iso9660
/* The following types of Rock Ridge records are being handled in some way:
* - [ ] PX (RR 4.1.1: POSIX file attributes)
* - [ ] PN (RR 4.1.2: POSIX device number)
* - [ ] SL (RR 4.1.3: symbolic link)
* - [ ] NM (RR 4.1.4: alternate name)
* - [ ] CL (RR 4.1.5.1: child link)
* - [ ] PL (RR 4.1.5.2: parent link)
* - [ ] RE (RR 4.1.5.3: relocated directory)
* - [ ] TF (RR 4.1.6: time stamp(s) for a file)
* - [ ] SF (RR 4.1.7: file data in sparse file format)
*/
const (
RockRidgeIdentifier = "RRIP_1991A"
RockRidgeVersion = 1
)
type RockRidgeNameEntry struct {
Flags byte
Name string
}
func suspHasRockRidge(se SystemUseEntrySlice) (bool, error) {
extensions, err := se.GetExtensionRecords()
if err != nil {
return false, err
}
for _, entry := range extensions {
if entry.Identifier == RockRidgeIdentifier && entry.Version == RockRidgeVersion {
return true, nil
}
}
return false, nil
}
func (s SystemUseEntrySlice) GetRockRidgeName() string {
var name string
for _, entry := range s {
// There is a continuation flag in the record, but we determine continuation
// by simply reading all NM entries.
if entry.Type() == "NM" {
nm := umarshalRockRidgeNameEntry(entry)
name += nm.Name
}
}
return name
}
func umarshalRockRidgeNameEntry(e SystemUseEntry) *RockRidgeNameEntry {
return &RockRidgeNameEntry{
Flags: e.Data()[0],
Name: string(e.Data()[1:]),
}
}