mirror of
https://github.com/paleotronic/diskm8.git
synced 2025-01-02 23:31:54 +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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/md5"
|
||||||
|
"encoding/gob"
|
||||||
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"runtime"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"crypto/md5"
|
|
||||||
"encoding/hex"
|
|
||||||
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"encoding/gob"
|
|
||||||
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/paleotronic/diskm8/disk"
|
"github.com/paleotronic/diskm8/disk"
|
||||||
"github.com/paleotronic/diskm8/loggy"
|
"github.com/paleotronic/diskm8/loggy"
|
||||||
|
@ -917,20 +917,19 @@ func (dsk *DSKWrapper) AppleDOSWriteFile(name string, kind FileType, data []byte
|
|||||||
data = append(header, data...)
|
data = append(header, data...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1st: check we have sufficient space...
|
// try get catalog entry - delete existing if match found
|
||||||
tsBlocks, dataBlocks, err := dsk.AppleDOSGetFreeSectors(len(data))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
fd, err := dsk.AppleDOSNamedCatalogEntry(name)
|
fd, err := dsk.AppleDOSNamedCatalogEntry(name)
|
||||||
//fmt.Println("FD=", fd)
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if kind != fd.Type() {
|
if kind != fd.Type() {
|
||||||
return errors.New("File type mismatch")
|
return errors.New("File type mismatch")
|
||||||
} else {
|
} else {
|
||||||
// need to delete this file...
|
// 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 {
|
if err != nil {
|
||||||
return err
|
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
|
// 2nd: check we can get a free catalog entry
|
||||||
sectorCount := len(dataBlocks)
|
sectorCount := len(dataBlocks)
|
||||||
|
|
||||||
@ -1058,6 +1063,8 @@ func (d *DSKWrapper) AppleDOSRemoveFile(fd *FileDescriptor) error {
|
|||||||
vtoc.SetTSFree(pair[0], pair[1], true)
|
vtoc.SetTSFree(pair[0], pair[1], true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vtoc.Publish(d)
|
||||||
|
|
||||||
fd.Data[0x00] = 0xff
|
fd.Data[0x00] = 0xff
|
||||||
fd.SetName("")
|
fd.SetName("")
|
||||||
return fd.Publish(d)
|
return fd.Publish(d)
|
||||||
|
16
main.go
16
main.go
@ -13,25 +13,19 @@ through as time goes by.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
|
"strings"
|
||||||
"flag"
|
"time"
|
||||||
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/paleotronic/diskm8/disk"
|
"github.com/paleotronic/diskm8/disk"
|
||||||
"github.com/paleotronic/diskm8/loggy"
|
"github.com/paleotronic/diskm8/loggy"
|
||||||
|
|
||||||
"runtime"
|
|
||||||
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/paleotronic/diskm8/panic"
|
"github.com/paleotronic/diskm8/panic"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user