Skip to content

Commit

Permalink
Merge pull request #5 from myjimnelson/0.4.1-branch
Browse files Browse the repository at this point in the history
0.4.1 Release / cia3
  • Loading branch information
midnightfreddie authored Apr 10, 2020
2 parents a7bc6e5 + de0f80f commit 89db57f
Show file tree
Hide file tree
Showing 27 changed files with 2,899 additions and 490 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
*.sav
*.csv
*.json
cmd/temp/
*.dll
node_modules/

# embeded files built by pkger
pkged.go

# built executables
civ3sat/civ3sat
Expand Down
44 changes: 44 additions & 0 deletions civ3decompress/readfile.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package civ3decompress

import (
"io/ioutil"
"os"
)

// ReadFile takes a filename and returns the decompressed file data or the raw data if it's not compressed. Also returns true if compressed.
func ReadFile(path string) ([]byte, bool, error) {
// Open file, hanlde errors, defer close
file, err := os.Open(path)
if err != nil {
return nil, false, FileError{err}
}
defer file.Close()

var compressed bool
var data []byte
header := make([]byte, 2)
_, err = file.Read(header)
if err != nil {
return nil, false, FileError{err}
}
// reset pointer to parse from beginning
_, err = file.Seek(0, 0)
if err != nil {
return nil, false, FileError{err}
}
switch {
case header[0] == 0x00 && (header[1] == 0x04 || header[1] == 0x05 || header[1] == 0x06):
compressed = true
data, err = Decompress(file)
if err != nil {
return nil, false, err
}
default:
// Not a compressed file. Proceeding with uncompressed stream.
data, err = ioutil.ReadFile(path)
if err != nil {
return nil, false, FileError{err}
}
}
return data, compressed, error(nil)
}
52 changes: 0 additions & 52 deletions civ3satgql/lookups.go

This file was deleted.

198 changes: 0 additions & 198 deletions civ3satgql/query.go

This file was deleted.

Loading

0 comments on commit 89db57f

Please sign in to comment.