1
0
mirror of https://github.com/pbnjay/grate.git synced 2024-12-05 03:58:34 +02:00

misc cleanups

This commit is contained in:
Jeremy Jay 2021-02-14 14:16:46 -05:00
parent d9793eb9dd
commit d9b725da93
5 changed files with 14 additions and 9 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
cmd/grate2tsv/results
testdata
*.pprof
*.pdf

View File

@ -1,7 +1,6 @@
package commonxl
import (
"log"
"strings"
"time"
)
@ -55,7 +54,7 @@ func timeFmtFunc(f string) FmtFunc {
}
t = x.ConvertToDate(fval)
}
log.Println("formatting date", t, "with", f, "=", t.Format(f))
//log.Println("formatting date", t, "with", f, "=", t.Format(f))
return t.Format(f)
}
}

View File

@ -3,6 +3,7 @@ package simple
import (
"errors"
"fmt"
"path/filepath"
"strconv"
"strings"
"time"
@ -19,7 +20,7 @@ type simpleFile struct {
// List the individual data tables within this source.
func (t *simpleFile) List() ([]string, error) {
return []string{t.filename}, nil
return []string{filepath.Base(t.filename)}, nil
}
func (t *simpleFile) Close() error {

View File

@ -14,6 +14,8 @@ import (
"io/ioutil"
"log"
"unicode/utf16"
"github.com/pbnjay/grate"
)
const fullAssertions = true
@ -111,14 +113,14 @@ func (d *Document) load(rx io.ReadSeeker) error {
h := &header{}
err = binary.Read(br, binary.LittleEndian, h)
if h.Signature != 0xe11ab1a1e011cfd0 {
return errors.New("ole2: invalid format")
return grate.ErrNotInFormat // errors.New("ole2: invalid format")
}
if h.ByteOrder != 0xFFFE {
return errors.New("ole2: invalid format")
return grate.ErrNotInFormat //errors.New("ole2: invalid format")
}
if fullAssertions {
if h.ClassID[0] != 0 || h.ClassID[1] != 0 {
return errors.New("ole2: invalid CLSID")
return grate.ErrNotInFormat //errors.New("ole2: invalid CLSID")
}
if h.MajorVersion != 3 && h.MajorVersion != 4 {
return errors.New("ole2: unknown major version")

View File

@ -4,8 +4,6 @@ import (
"fmt"
"io"
"os"
"github.com/pbnjay/grate"
)
// Open a Compound File Binary Format document.
@ -17,7 +15,7 @@ func Open(filename string) (*Document, error) {
}
err = d.load(f)
if err != nil {
return nil, grate.WrapErr(err, grate.ErrNotInFormat)
return nil, err
}
return d, nil
}