apparently seek also can fail
This commit is contained in:
parent
24dad18c81
commit
8fe782253b
|
@ -310,7 +310,7 @@ func setValues(descr fileDescription, binpath string, vals map[string]string) {
|
||||||
f, err := os.OpenFile(binpath, os.O_RDWR, 0666)
|
f, err := os.OpenFile(binpath, os.O_RDWR, 0666)
|
||||||
optPanic("failed to write-open binary", err)
|
optPanic("failed to write-open binary", err)
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
for _, part := range descr.parts {
|
for i, part := range descr.parts {
|
||||||
needSeek := true
|
needSeek := true
|
||||||
if part.name != "" {
|
if part.name != "" {
|
||||||
if val, ok := vals[part.name]; ok {
|
if val, ok := vals[part.name]; ok {
|
||||||
|
@ -319,7 +319,8 @@ func setValues(descr fileDescription, binpath string, vals map[string]string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if needSeek {
|
if needSeek {
|
||||||
f.Seek(part.handling.bytes, 1)
|
_, err = f.Seek(part.handling.bytes, 1)
|
||||||
|
optPanic("set: could not advance in file (stuck at part "+strconv.Itoa(i)+"name: "+part.name+")", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -329,9 +330,10 @@ func getValues(descr fileDescription, binpath string) map[string]string {
|
||||||
f, err := os.Open(binpath)
|
f, err := os.Open(binpath)
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
optPanic("failed to open binary", err)
|
optPanic("failed to open binary", err)
|
||||||
for _, part := range descr.parts {
|
for i, part := range descr.parts {
|
||||||
if part.name == "" {
|
if part.name == "" {
|
||||||
f.Seek(part.handling.bytes, 1)
|
_, err = f.Seek(part.handling.bytes, 1)
|
||||||
|
optPanic("get: could not advance in file (stuck at part "+strconv.Itoa(i)+"name: "+part.name+")", err)
|
||||||
} else {
|
} else {
|
||||||
vals[part.name] = part.handling.readFrom(f, descr.byteOrder)
|
vals[part.name] = part.handling.readFrom(f, descr.byteOrder)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user