-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopen.go
60 lines (50 loc) · 1.01 KB
/
open.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 mpq
import (
"os"
"path/filepath"
)
// Open will open the MoPaQ [Archive] specified by name
func Open(name string) (archive *Archive, err error) {
archive = new(Archive)
// Get fully qualified path to file
archive.path, err = filepath.Abs(name)
if err != nil {
// Just use regular path if this errors
archive.path = name
err = nil
}
// open fd to archive
file, err := os.Open(archive.path)
if err != nil {
return
}
// read user data and header
err = archive.read_header(file)
if err != nil {
return
}
// read hash table
err = archive.read_hash_table(file)
if err != nil {
return
}
// read block table and hi block table
err = archive.read_block_table(file)
if err != nil {
return
}
// read HET table
if err = archive.read_het_table(file); err != nil {
return
}
// read BET table
if err = archive.read_bet_table(file); err != nil {
return
}
// close fd
err = file.Close()
if err != nil {
return
}
return
}