mirror of
https://github.com/paleotronic/diskm8.git
synced 2024-12-21 03:29:58 +00:00
fix dos write
This commit is contained in:
parent
a6d47bbafa
commit
16c8a2100d
17
data.go
17
data.go
@ -1,21 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"encoding/gob"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
|
||||
"os"
|
||||
|
||||
"strings"
|
||||
|
||||
"encoding/gob"
|
||||
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/paleotronic/diskm8/disk"
|
||||
"github.com/paleotronic/diskm8/loggy"
|
||||
|
@ -917,20 +917,19 @@ func (dsk *DSKWrapper) AppleDOSWriteFile(name string, kind FileType, data []byte
|
||||
data = append(header, data...)
|
||||
}
|
||||
|
||||
// 1st: check we have sufficient space...
|
||||
tsBlocks, dataBlocks, err := dsk.AppleDOSGetFreeSectors(len(data))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// try get catalog entry - delete existing if match found
|
||||
fd, err := dsk.AppleDOSNamedCatalogEntry(name)
|
||||
//fmt.Println("FD=", fd)
|
||||
if err == nil {
|
||||
if kind != fd.Type() {
|
||||
return errors.New("File type mismatch")
|
||||
} else {
|
||||
// need to delete this file...
|
||||
err = dsk.AppleDOSDeleteFile(name)
|
||||
err = dsk.AppleDOSRemoveFile(fd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// reread vtoc here
|
||||
vtoc, err = dsk.AppleDOSGetVTOC()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -942,6 +941,12 @@ func (dsk *DSKWrapper) AppleDOSWriteFile(name string, kind FileType, data []byte
|
||||
}
|
||||
}
|
||||
|
||||
// 1st: check we have sufficient space...
|
||||
tsBlocks, dataBlocks, err := dsk.AppleDOSGetFreeSectors(len(data))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 2nd: check we can get a free catalog entry
|
||||
sectorCount := len(dataBlocks)
|
||||
|
||||
@ -1058,6 +1063,8 @@ func (d *DSKWrapper) AppleDOSRemoveFile(fd *FileDescriptor) error {
|
||||
vtoc.SetTSFree(pair[0], pair[1], true)
|
||||
}
|
||||
|
||||
vtoc.Publish(d)
|
||||
|
||||
fd.Data[0x00] = 0xff
|
||||
fd.SetName("")
|
||||
return fd.Publish(d)
|
||||
|
16
main.go
16
main.go
@ -13,25 +13,19 @@ through as time goes by.
|
||||
*/
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"runtime/debug"
|
||||
|
||||
"flag"
|
||||
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/paleotronic/diskm8/disk"
|
||||
"github.com/paleotronic/diskm8/loggy"
|
||||
|
||||
"runtime"
|
||||
|
||||
"strings"
|
||||
|
||||
"time"
|
||||
|
||||
"github.com/paleotronic/diskm8/panic"
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user