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

This commit is contained in:
Felix Pojtinger
2021-12-13 00:26:30 +01:00
parent 734df25820
commit 58b407cd4f
34 changed files with 506 additions and 340 deletions
-5
View File
@@ -1,5 +0,0 @@
package hardware
type DriveConfig struct {
Drive string
}
+3 -10
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)
}
+3 -10
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)
}