diff --git a/cmd/vinegar/binary_setup.go b/cmd/vinegar/binary_setup.go index 25b2398..c083e7f 100644 --- a/cmd/vinegar/binary_setup.go +++ b/cmd/vinegar/binary_setup.go @@ -6,7 +6,10 @@ import ( "os" "path/filepath" "sort" + "errors" + "strings" + cp "github.com/otiai10/copy" "github.com/vinegarhq/vinegar/internal/dirs" "github.com/vinegarhq/vinegar/roblox" boot "github.com/vinegarhq/vinegar/roblox/bootstrapper" @@ -59,8 +62,16 @@ func (b *Binary) Setup() error { return fmt.Errorf("apply fflags: %w", err) } - if err := dirs.OverlayDir(b.Dir); err != nil { - return fmt.Errorf("overlay dir: %w", err) + overlayDir := filepath.Join(dirs.Overlays, strings.ToLower(b.Type.String())) + _, err := os.Stat(overlayDir) + if err != nil && !errors.Is(err, os.ErrNotExist) { + return fmt.Errorf("stat overlay: %w", err) + } else if err == nil { + slog.Info("Copying Overlay directory's files", "src", overlayDir, "path", b.Dir) + + if err := cp.Copy(overlayDir, b.Dir); err != nil { + return fmt.Errorf("overlay dir: %w", err) + } } if err := b.SetupDxvk(); err != nil { diff --git a/cmd/vinegar/main.go b/cmd/vinegar/main.go index 38e2fa5..30c2403 100644 --- a/cmd/vinegar/main.go +++ b/cmd/vinegar/main.go @@ -146,4 +146,4 @@ func Delete() error { } return nil -} \ No newline at end of file +} diff --git a/internal/dirs/copy.go b/internal/dirs/copy.go deleted file mode 100644 index ef31b64..0000000 --- a/internal/dirs/copy.go +++ /dev/null @@ -1,22 +0,0 @@ -package dirs - -import ( - "errors" - "log/slog" - "os" - - cp "github.com/otiai10/copy" -) - -func OverlayDir(dir string) error { - _, err := os.Stat(Overlay) - if errors.Is(err, os.ErrNotExist) { - return nil - } else if err != nil { - return err - } - - slog.Info("Copying Overlay directory's files", "dir", dir) - - return cp.Copy(Overlay, dir) -} diff --git a/internal/dirs/dirs.go b/internal/dirs/dirs.go index c5dbfec..d040280 100644 --- a/internal/dirs/dirs.go +++ b/internal/dirs/dirs.go @@ -11,7 +11,7 @@ var ( Cache = filepath.Join(xdg.CacheHome, "vinegar") Config = filepath.Join(xdg.ConfigHome, "vinegar") Data = filepath.Join(xdg.DataHome, "vinegar") - Overlay = filepath.Join(Config, "overlay") + Overlays = filepath.Join(Config, "overlays") Downloads = filepath.Join(Cache, "downloads") Logs = filepath.Join(Cache, "logs") Prefixes = filepath.Join(Data, "prefixes") @@ -19,6 +19,8 @@ var ( // Deprecated: Vinegar supports multiple wine prefixes Prefix = filepath.Join(Data, "prefix") + // Deprecated: Vinegar supports multiple overlays for each Player and Studio + Overlay = filepath.Join(Config, "overlay") ) func Mkdirs(dirs ...string) error {