Integrate real filesystem with interface abstraction
- Define pool.FileSystem interface in internal/io/pool/filesystem.go - Move DirEntry interface to internal/io/pool/types/types.go to break the pool <-> mock import cycle - Implement real.FileSystem with atomic writes (temp file + os.Rename) - Update mock.FileSystem to satisfy pool.FileSystem interface - Update worker pool tasks to accept pool.FileSystem interface - Update main.go to use RealFileSystem by default, with -root flag - Update all browser/editor/test references to types.DirEntry
This commit is contained in:
+16
-1
@@ -1,8 +1,10 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
|
||||
"gioui.org/app"
|
||||
@@ -13,6 +15,7 @@ import (
|
||||
"gioui.org/io/key"
|
||||
|
||||
"pad/internal/editor"
|
||||
"pad/internal/io/pool/real"
|
||||
"pad/internal/ui"
|
||||
)
|
||||
|
||||
@@ -33,7 +36,19 @@ func run(w *app.Window) error {
|
||||
log.Printf("run: starting")
|
||||
var ops op.Ops
|
||||
shaper := text.NewShaper(text.WithCollection(gofont.Collection()))
|
||||
logic := editor.NewLogic(nil)
|
||||
|
||||
// Determine root directory for real filesystem
|
||||
rootDir := flag.String("root", ".", "root directory for the filesystem")
|
||||
flag.Parse()
|
||||
|
||||
abs, err := filepath.Abs(*rootDir)
|
||||
if err != nil {
|
||||
log.Fatalf("invalid root directory: %v", err)
|
||||
}
|
||||
fs := &real.RealFileSystem{Root: abs}
|
||||
log.Printf("using filesystem at %s", abs)
|
||||
|
||||
logic := editor.NewLogic(fs)
|
||||
renderer := ui.New(ui.Theme{FontSize: 14}, shaper, logic.State())
|
||||
var mu sync.Mutex
|
||||
var elems []ui.Element
|
||||
|
||||
Reference in New Issue
Block a user