refactor: Use explicit reader/writer instead of filepath for drive
This commit is contained in:
@@ -1,5 +0,0 @@
|
||||
package hardware
|
||||
|
||||
type DriveConfig struct {
|
||||
Drive string
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user