mirror of
https://github.com/zellyn/diskii.git
synced 2024-11-21 08:32:21 +00:00
Add go report card; fix vet, lint, etc. warnings
This commit is contained in:
parent
34a26dd1d6
commit
e376f8ee41
@ -15,6 +15,8 @@ cross-platform.
|
||||
Its major disadvantage is that it mostly doesn't exist yet.
|
||||
|
||||
[![Build Status](https://travis-ci.org/zellyn/diskii.svg?branch=master)](https://travis-ci.org/zellyn/diskii)
|
||||
[![Report Card](https://goreportcard.com/badge/github.com/zellyn/diskii)](https://goreportcard.com/report/github.com/zellyn/diskii)
|
||||
|
||||
|
||||
It rhymes with “whiskey”.
|
||||
|
||||
|
@ -8,8 +8,6 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/zellyn/diskii/lib/disk"
|
||||
_ "github.com/zellyn/diskii/lib/dos3"
|
||||
_ "github.com/zellyn/diskii/lib/supermon"
|
||||
)
|
||||
|
||||
var shortnames bool // flag for whether to print short filenames
|
||||
|
@ -8,8 +8,6 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/zellyn/diskii/lib/disk"
|
||||
_ "github.com/zellyn/diskii/lib/dos3"
|
||||
_ "github.com/zellyn/diskii/lib/supermon"
|
||||
)
|
||||
|
||||
var missingok bool // flag for whether to consider deleting a nonexistent file okay
|
||||
|
@ -8,8 +8,6 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/zellyn/diskii/lib/disk"
|
||||
_ "github.com/zellyn/diskii/lib/dos3"
|
||||
_ "github.com/zellyn/diskii/lib/supermon"
|
||||
)
|
||||
|
||||
// dumpCmd represents the dump command, used to dump the raw contents
|
||||
|
@ -8,8 +8,6 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/zellyn/diskii/lib/disk"
|
||||
_ "github.com/zellyn/diskii/lib/dos3"
|
||||
_ "github.com/zellyn/diskii/lib/supermon"
|
||||
)
|
||||
|
||||
var all bool // flag for whether to show all filetypes
|
||||
|
@ -8,9 +8,7 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/zellyn/diskii/lib/disk"
|
||||
_ "github.com/zellyn/diskii/lib/dos3"
|
||||
"github.com/zellyn/diskii/lib/helpers"
|
||||
_ "github.com/zellyn/diskii/lib/supermon"
|
||||
)
|
||||
|
||||
var filetypeName string // flag for file type
|
||||
|
@ -11,8 +11,9 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Various DOS33 disk characteristics.
|
||||
const (
|
||||
DOS33Tracks = 35 // Tracks per disk
|
||||
DOS33Tracks = 35
|
||||
DOS33Sectors = 16 // Sectors per track
|
||||
// DOS33DiskBytes is the number of bytes on a DOS 3.3 disk.
|
||||
DOS33DiskBytes = 143360 // 35 tracks * 16 sectors * 256 bytes
|
||||
@ -39,6 +40,8 @@ type TrackSector struct {
|
||||
Sector byte
|
||||
}
|
||||
|
||||
// SectorDisk is the interface use to read and write disks by physical
|
||||
// (matches sector header) sector number.
|
||||
type SectorDisk interface {
|
||||
// ReadPhysicalSector reads a single physical sector from the disk. It
|
||||
// always returns 256 byes.
|
||||
@ -54,6 +57,8 @@ type SectorDisk interface {
|
||||
Write(io.Writer) (int, error)
|
||||
}
|
||||
|
||||
// LogicalSectorDisk is the interface used to read and write a disk by
|
||||
// *logical* sector number.
|
||||
type LogicalSectorDisk interface {
|
||||
// ReadLogicalSector reads a single logical sector from the disk. It
|
||||
// always returns 256 byes.
|
||||
@ -78,6 +83,8 @@ type MappedDisk struct {
|
||||
|
||||
var _ LogicalSectorDisk = MappedDisk{}
|
||||
|
||||
// NewMappedDisk returns a MappedDisk with the given
|
||||
// logical-to-physical sector mapping.
|
||||
func NewMappedDisk(sd SectorDisk, logicalToPhysical []byte) (MappedDisk, error) {
|
||||
if logicalToPhysical != nil && len(logicalToPhysical) != int(sd.Sectors()) {
|
||||
return MappedDisk{}, fmt.Errorf("NewMappedDisk called on a disk image with %d sectors per track, but a mapping of length %d", sd.Sectors(), len(logicalToPhysical))
|
||||
|
@ -29,7 +29,7 @@ func LoadDSK(filename string) (DSK, error) {
|
||||
}
|
||||
// TODO(zellyn): handle 13-sector disks.
|
||||
if len(bb) != DOS33DiskBytes {
|
||||
return DSK{}, fmt.Errorf("Expected file %q to contain %d bytes, but got %d.", filename, DOS33DiskBytes, len(bb))
|
||||
return DSK{}, fmt.Errorf("expected file %q to contain %d bytes, but got %d", filename, DOS33DiskBytes, len(bb))
|
||||
}
|
||||
return DSK{
|
||||
data: bb,
|
||||
|
@ -11,6 +11,7 @@ import "fmt"
|
||||
// the ProDOS/SOS filetype byte definitions in the range 00-FF.
|
||||
type Filetype int
|
||||
|
||||
// Filetypes.
|
||||
const (
|
||||
FiletypeTypeless Filetype = 0x00 // | both | Typeless file
|
||||
FiletypeBadBlocks Filetype = 0x01 // | both | Bad blocks file
|
||||
|
@ -19,6 +19,7 @@ const (
|
||||
VTOCSector = 0
|
||||
)
|
||||
|
||||
// DiskSector represents a track and sector.
|
||||
type DiskSector struct {
|
||||
Track byte
|
||||
Sector byte
|
||||
@ -185,6 +186,8 @@ func (v *VTOC) FromSector(data []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// DefaultVTOC returns a new, empty VTOC with values set to their
|
||||
// defaults.
|
||||
func DefaultVTOC() VTOC {
|
||||
v := VTOC{
|
||||
CatalogTrack: 0x11,
|
||||
@ -253,9 +256,9 @@ func (cs *CatalogSector) FromSector(data []byte) error {
|
||||
// Filetype is the type for dos 3.3 filetype+locked status byte.
|
||||
type Filetype byte
|
||||
|
||||
// The DOS3 filetypes.
|
||||
const (
|
||||
// Hex 80+file type - file is locked,
|
||||
// Hex 00+file type - file is not locked.
|
||||
// FiletypeLocked is just setting the high bit on other file types.
|
||||
FiletypeLocked Filetype = 0x80
|
||||
|
||||
FiletypeText Filetype = 0x00 // Text file
|
||||
@ -268,8 +271,10 @@ const (
|
||||
FiletypeB Filetype = 0x40 // B type file
|
||||
)
|
||||
|
||||
// FileDescStatus is the type used to mark file descriptor status.
|
||||
type FileDescStatus int
|
||||
|
||||
// The three actual file descriptor status values.
|
||||
const (
|
||||
FileDescStatusNormal FileDescStatus = iota
|
||||
FileDescStatusDeleted
|
||||
|
@ -85,6 +85,9 @@ func TestReadCatalog(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
fds, deleted, err := ReadCatalog(dsk)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
fdsWant := []struct {
|
||||
locked bool
|
||||
|
@ -9,7 +9,8 @@ import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Copy of errors.New, so you this package can be imported instead.
|
||||
// New is a copy of errors.New, so this package can be imported as a
|
||||
// replacement.
|
||||
func New(text string) error {
|
||||
return errors.New(text)
|
||||
}
|
||||
|
@ -9,6 +9,8 @@ import (
|
||||
"os"
|
||||
)
|
||||
|
||||
// FileContentsOrStdIn returns the contents of a file, unless the file
|
||||
// is "-", in which case it reads from stdin.
|
||||
func FileContentsOrStdIn(s string) ([]byte, error) {
|
||||
if s == "-" {
|
||||
return ioutil.ReadAll(os.Stdin)
|
||||
|
@ -473,7 +473,7 @@ func (st SymbolTable) DeleteSymbol(name string) bool {
|
||||
// already exists with a different address, it deletes it first.
|
||||
func (st SymbolTable) AddSymbol(name string, address uint16) error {
|
||||
if address == 0 {
|
||||
return fmt.Errorf("cannot set symbol %q to address 0")
|
||||
return fmt.Errorf("cannot set symbol %q to address 0", name)
|
||||
}
|
||||
hash := addrHash(address)
|
||||
pos := -1
|
||||
@ -584,7 +584,7 @@ func (st SymbolTable) ParseCompoundSymbol(name string) (address uint16, symAddre
|
||||
if _, err := encodeSymbol(name); err != nil {
|
||||
return 0, 0, name, nil
|
||||
}
|
||||
return 0, 0, "", fmt.Errorf("%q is not a valid symbol name or address")
|
||||
return 0, 0, "", fmt.Errorf("%q is not a valid symbol name or address", name)
|
||||
}
|
||||
|
||||
if parts[0] == "" {
|
||||
@ -630,7 +630,7 @@ func (st SymbolTable) FilesForCompoundName(filename string) (numFile byte, named
|
||||
return 0, 0, "", fmt.Errorf("invalid file number: %q", parts[0])
|
||||
}
|
||||
if numFile2 := parseAddressFilename(parts[1]); numFile2 != 0 {
|
||||
return 0, 0, "", fmt.Errorf("cannot valid file number (%q) as a filename")
|
||||
return 0, 0, "", fmt.Errorf("cannot use valid file number (%q) as a filename", parts[1])
|
||||
}
|
||||
namedFile, err = st.FileForName(parts[1])
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user