refactor: Use explicit reader/writer instead of filepath for drive

This commit is contained in:
Felicitas Pojtinger
2021-12-13 00:26:30 +01:00
parent 8ef3530b20
commit 6bd31d356c
34 changed files with 506 additions and 340 deletions

View File

@@ -1,5 +0,0 @@
package hardware
type DriveConfig struct {
Drive string
}

View File

@@ -1,19 +1,12 @@
package hardware
import (
"os"
"github.com/pojntfx/stfs/internal/mtio"
"github.com/pojntfx/stfs/pkg/config"
)
func Eject(
state DriveConfig,
state config.DriveConfig,
) error {
f, err := os.OpenFile(state.Drive, os.O_RDONLY, os.ModeCharDevice)
if err != nil {
return err
}
defer f.Close()
return mtio.EjectTape(f)
return mtio.EjectTape(state.Drive)
}

View File

@@ -1,19 +1,12 @@
package hardware
import (
"os"
"github.com/pojntfx/stfs/internal/mtio"
"github.com/pojntfx/stfs/pkg/config"
)
func Tell(
state DriveConfig,
state config.DriveConfig,
) (int64, error) {
f, err := os.OpenFile(state.Drive, os.O_RDONLY, os.ModeCharDevice)
if err != nil {
return -1, err
}
defer f.Close()
return mtio.GetCurrentRecordFromTape(f)
return mtio.GetCurrentRecordFromTape(state.Drive)
}