Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions dbf.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type DbfField struct {

// Create a new dbase table from the scratch
func New() *DbfTable {
// Create and pupulate DbaseTable struct
// Create and populate DbaseTable struct
dt := new(DbfTable)

// read dbase table header information
Expand Down Expand Up @@ -96,7 +96,7 @@ func LoadFile(fileName string) (table *DbfTable, err error) {
if err != nil {
return nil, err
}
// Create and pupulate DbaseTable struct
// Create and populate DbaseTable struct
dt := new(DbfTable)
dt.loading = true
// set DbfTable dataStore slice that will store the complete file in memory
Expand Down Expand Up @@ -165,8 +165,10 @@ func LoadFile(fileName string) (table *DbfTable, err error) {

// SaveFile dbf file.
func (dt *DbfTable) SaveFile(filename string) error {
// don't forget to add dbase end of file marker which is 1Ah
dt.dataStore = appendSlice(dt.dataStore, []byte{0x1A})
// ensure the last byte in the data store is the dBase end-of-file marker (0x1A)
if dt.dataStore[len(dt.dataStore)-1] != 0x1A {
dt.dataStore[len(dt.dataStore)-1] = 0x1A
}
f, err := os.Create(filename)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/Bowbaq/dbf
module github.com/Riznyk01/dbf

go 1.15
go 1.22

require (
github.com/pkg/errors v0.9.1
Expand Down