mirror of
https://github.com/JetSetIlly/Gopher2600.git
synced 2024-06-23 15:03:14 -04:00
renamed paths package to resources package
ResourcePath() is now called JoinPath() UniqueFilename() moved to a new package named unique and renamed to Filename()
This commit is contained in:
parent
0025d2ee3a
commit
e5bd938b41
|
@ -19,8 +19,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/jetsetilly/gopher2600/hardware/memory/memorymap"
|
"github.com/jetsetilly/gopher2600/hardware/memory/memorymap"
|
||||||
"github.com/jetsetilly/gopher2600/paths"
|
|
||||||
"github.com/jetsetilly/gopher2600/prefs"
|
"github.com/jetsetilly/gopher2600/prefs"
|
||||||
|
"github.com/jetsetilly/gopher2600/resources"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Preferences struct {
|
type Preferences struct {
|
||||||
|
@ -50,7 +50,7 @@ func newPreferences(dsm *Disassembly) (*Preferences, error) {
|
||||||
p.mirrorOrigin = memorymap.OriginCartFxxxMirror
|
p.mirrorOrigin = memorymap.OriginCartFxxxMirror
|
||||||
|
|
||||||
// save server using the prefs package
|
// save server using the prefs package
|
||||||
pth, err := paths.ResourcePath(prefs.DefaultPrefsFile)
|
pth, err := resources.JoinPath(prefs.DefaultPrefsFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,11 +37,11 @@ import (
|
||||||
"github.com/jetsetilly/gopher2600/hiscore"
|
"github.com/jetsetilly/gopher2600/hiscore"
|
||||||
"github.com/jetsetilly/gopher2600/logger"
|
"github.com/jetsetilly/gopher2600/logger"
|
||||||
"github.com/jetsetilly/gopher2600/modalflag"
|
"github.com/jetsetilly/gopher2600/modalflag"
|
||||||
"github.com/jetsetilly/gopher2600/paths"
|
|
||||||
"github.com/jetsetilly/gopher2600/performance"
|
"github.com/jetsetilly/gopher2600/performance"
|
||||||
"github.com/jetsetilly/gopher2600/playmode"
|
"github.com/jetsetilly/gopher2600/playmode"
|
||||||
"github.com/jetsetilly/gopher2600/recorder"
|
"github.com/jetsetilly/gopher2600/recorder"
|
||||||
"github.com/jetsetilly/gopher2600/regression"
|
"github.com/jetsetilly/gopher2600/regression"
|
||||||
|
"github.com/jetsetilly/gopher2600/resources"
|
||||||
"github.com/jetsetilly/gopher2600/statsview"
|
"github.com/jetsetilly/gopher2600/statsview"
|
||||||
"github.com/jetsetilly/gopher2600/wavwriter"
|
"github.com/jetsetilly/gopher2600/wavwriter"
|
||||||
)
|
)
|
||||||
|
@ -414,7 +414,7 @@ func play(md *modalflag.Modes, sync *mainSync) error {
|
||||||
func debug(md *modalflag.Modes, sync *mainSync) error {
|
func debug(md *modalflag.Modes, sync *mainSync) error {
|
||||||
md.NewMode()
|
md.NewMode()
|
||||||
|
|
||||||
defInitScript, err := paths.ResourcePath(defaultInitScript)
|
defInitScript, err := resources.JoinPath(defaultInitScript)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,8 @@
|
||||||
package crt
|
package crt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/jetsetilly/gopher2600/paths"
|
|
||||||
"github.com/jetsetilly/gopher2600/prefs"
|
"github.com/jetsetilly/gopher2600/prefs"
|
||||||
|
"github.com/jetsetilly/gopher2600/resources"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Preferences struct {
|
type Preferences struct {
|
||||||
|
@ -84,7 +84,7 @@ func NewPreferences() (*Preferences, error) {
|
||||||
p.SetDefaults()
|
p.SetDefaults()
|
||||||
|
|
||||||
// save server using the prefs package
|
// save server using the prefs package
|
||||||
pth, err := paths.ResourcePath(prefs.DefaultPrefsFile)
|
pth, err := resources.JoinPath(prefs.DefaultPrefsFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,8 @@
|
||||||
package sdlaudio
|
package sdlaudio
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/jetsetilly/gopher2600/paths"
|
|
||||||
"github.com/jetsetilly/gopher2600/prefs"
|
"github.com/jetsetilly/gopher2600/prefs"
|
||||||
|
"github.com/jetsetilly/gopher2600/resources"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Preferences struct {
|
type Preferences struct {
|
||||||
|
@ -36,7 +36,7 @@ func NewPreferences() (*Preferences, error) {
|
||||||
p.SetDefaults()
|
p.SetDefaults()
|
||||||
|
|
||||||
// save server using the prefs package
|
// save server using the prefs package
|
||||||
pth, err := paths.ResourcePath(prefs.DefaultPrefsFile)
|
pth, err := resources.JoinPath(prefs.DefaultPrefsFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ import (
|
||||||
|
|
||||||
"github.com/jetsetilly/gopher2600/gui/sdlimgui/framebuffer"
|
"github.com/jetsetilly/gopher2600/gui/sdlimgui/framebuffer"
|
||||||
"github.com/jetsetilly/gopher2600/hardware/television/specification"
|
"github.com/jetsetilly/gopher2600/hardware/television/specification"
|
||||||
"github.com/jetsetilly/gopher2600/paths"
|
"github.com/jetsetilly/gopher2600/resources/unique"
|
||||||
)
|
)
|
||||||
|
|
||||||
type screenshotMode int
|
type screenshotMode int
|
||||||
|
@ -95,9 +95,9 @@ func (sh *screenshotSequencer) startProcess(mode screenshotMode) {
|
||||||
|
|
||||||
sh.crtProcessing = sh.img.crtPrefs.Enabled.Get().(bool)
|
sh.crtProcessing = sh.img.crtPrefs.Enabled.Get().(bool)
|
||||||
if sh.crtProcessing {
|
if sh.crtProcessing {
|
||||||
sh.baseFilename = paths.UniqueFilename("crt", sh.img.vcs.Mem.Cart.ShortName)
|
sh.baseFilename = unique.Filename("crt", sh.img.vcs.Mem.Cart.ShortName)
|
||||||
} else {
|
} else {
|
||||||
sh.baseFilename = paths.UniqueFilename("pix", sh.img.vcs.Mem.Cart.ShortName)
|
sh.baseFilename = unique.Filename("pix", sh.img.vcs.Mem.Cart.ShortName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,8 @@ package sdlimgui
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/jetsetilly/gopher2600/paths"
|
|
||||||
"github.com/jetsetilly/gopher2600/prefs"
|
"github.com/jetsetilly/gopher2600/prefs"
|
||||||
|
"github.com/jetsetilly/gopher2600/resources"
|
||||||
)
|
)
|
||||||
|
|
||||||
// unified preferences for both modes (debugger and playmode). preferences
|
// unified preferences for both modes (debugger and playmode). preferences
|
||||||
|
@ -67,7 +67,7 @@ func newPreferences(img *SdlImgui) (*preferences, error) {
|
||||||
p.superchargerNotifications.Set(true)
|
p.superchargerNotifications.Set(true)
|
||||||
|
|
||||||
// setup preferences
|
// setup preferences
|
||||||
pth, err := paths.ResourcePath(prefs.DefaultPrefsFile)
|
pth, err := resources.JoinPath(prefs.DefaultPrefsFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ func (p *preferences) setWindowPreferences(isPlayMode bool) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// setup preferences
|
// setup preferences
|
||||||
pth, err := paths.ResourcePath(prefs.DefaultPrefsFile)
|
pth, err := resources.JoinPath(prefs.DefaultPrefsFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,8 @@ import (
|
||||||
"github.com/jetsetilly/gopher2600/hardware"
|
"github.com/jetsetilly/gopher2600/hardware"
|
||||||
"github.com/jetsetilly/gopher2600/hardware/television"
|
"github.com/jetsetilly/gopher2600/hardware/television"
|
||||||
"github.com/jetsetilly/gopher2600/logger"
|
"github.com/jetsetilly/gopher2600/logger"
|
||||||
"github.com/jetsetilly/gopher2600/paths"
|
|
||||||
"github.com/jetsetilly/gopher2600/reflection"
|
"github.com/jetsetilly/gopher2600/reflection"
|
||||||
|
"github.com/jetsetilly/gopher2600/resources"
|
||||||
"github.com/jetsetilly/gopher2600/userinput"
|
"github.com/jetsetilly/gopher2600/userinput"
|
||||||
"github.com/veandco/go-sdl2/sdl"
|
"github.com/veandco/go-sdl2/sdl"
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ func NewSdlImgui(tv *television.Television) (*SdlImgui, error) {
|
||||||
return nil, curated.Errorf("sdlimgui: %v", err)
|
return nil, curated.Errorf("sdlimgui: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
iniPath, err := paths.ResourcePath(imguiIniFile)
|
iniPath, err := resources.JoinPath(imguiIniFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, curated.Errorf("sdlimgui: %v", err)
|
return nil, curated.Errorf("sdlimgui: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ import (
|
||||||
"github.com/jetsetilly/gopher2600/disassembly/coprocessor"
|
"github.com/jetsetilly/gopher2600/disassembly/coprocessor"
|
||||||
"github.com/jetsetilly/gopher2600/hardware/memory/cartridge/harmony/arm7tdmi"
|
"github.com/jetsetilly/gopher2600/hardware/memory/cartridge/harmony/arm7tdmi"
|
||||||
"github.com/jetsetilly/gopher2600/logger"
|
"github.com/jetsetilly/gopher2600/logger"
|
||||||
"github.com/jetsetilly/gopher2600/paths"
|
"github.com/jetsetilly/gopher2600/resources/unique"
|
||||||
)
|
)
|
||||||
|
|
||||||
const winCoProcLastExecutionID = "Last Execution"
|
const winCoProcLastExecutionID = "Last Execution"
|
||||||
|
@ -270,10 +270,10 @@ func (win *winCoProcLastExecution) save() {
|
||||||
var fn string
|
var fn string
|
||||||
if win.showLastExecution {
|
if win.showLastExecution {
|
||||||
itr = win.img.dbg.Disasm.Coprocessor.NewIteration(coprocessor.LastExecution)
|
itr = win.img.dbg.Disasm.Coprocessor.NewIteration(coprocessor.LastExecution)
|
||||||
fn = paths.UniqueFilename("coproc_lastexecution", "")
|
fn = unique.Filename("coproc_lastexecution", "")
|
||||||
} else {
|
} else {
|
||||||
itr = win.img.dbg.Disasm.Coprocessor.NewIteration(coprocessor.Disassembly)
|
itr = win.img.dbg.Disasm.Coprocessor.NewIteration(coprocessor.Disassembly)
|
||||||
fn = paths.UniqueFilename("coproc_disasm", "")
|
fn = unique.Filename("coproc_disasm", "")
|
||||||
}
|
}
|
||||||
|
|
||||||
f, err := os.Create(fmt.Sprintf("%s.csv", fn))
|
f, err := os.Create(fmt.Sprintf("%s.csv", fn))
|
||||||
|
|
|
@ -24,7 +24,7 @@ import (
|
||||||
"github.com/jetsetilly/gopher2600/emulation"
|
"github.com/jetsetilly/gopher2600/emulation"
|
||||||
"github.com/jetsetilly/gopher2600/gui/fonts"
|
"github.com/jetsetilly/gopher2600/gui/fonts"
|
||||||
"github.com/jetsetilly/gopher2600/logger"
|
"github.com/jetsetilly/gopher2600/logger"
|
||||||
"github.com/jetsetilly/gopher2600/paths"
|
"github.com/jetsetilly/gopher2600/resources/unique"
|
||||||
|
|
||||||
"github.com/inkyblackness/imgui-go/v4"
|
"github.com/inkyblackness/imgui-go/v4"
|
||||||
)
|
)
|
||||||
|
@ -237,7 +237,7 @@ func (win *winTerm) draw() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (win *winTerm) saveOutput() {
|
func (win *winTerm) saveOutput() {
|
||||||
fn := paths.UniqueFilename("terminal", "")
|
fn := unique.Filename("terminal", "")
|
||||||
f, err := os.Create(fn)
|
f, err := os.Create(fn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
win.output = append(win.output, terminalOutput{
|
win.output = append(win.output, terminalOutput{
|
||||||
|
|
|
@ -19,8 +19,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
|
||||||
"github.com/jetsetilly/gopher2600/paths"
|
|
||||||
"github.com/jetsetilly/gopher2600/prefs"
|
"github.com/jetsetilly/gopher2600/prefs"
|
||||||
|
"github.com/jetsetilly/gopher2600/resources"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -45,7 +45,7 @@ func newPreferences() (*Preferences, error) {
|
||||||
p.ID.SetMaxLen(MaxIDLength)
|
p.ID.SetMaxLen(MaxIDLength)
|
||||||
|
|
||||||
// save server using the prefs package
|
// save server using the prefs package
|
||||||
pth, err := paths.ResourcePath(prefs.DefaultPrefsFile)
|
pth, err := resources.JoinPath(prefs.DefaultPrefsFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ import (
|
||||||
|
|
||||||
"github.com/jetsetilly/gopher2600/curated"
|
"github.com/jetsetilly/gopher2600/curated"
|
||||||
"github.com/jetsetilly/gopher2600/logger"
|
"github.com/jetsetilly/gopher2600/logger"
|
||||||
"github.com/jetsetilly/gopher2600/paths"
|
"github.com/jetsetilly/gopher2600/resources"
|
||||||
)
|
)
|
||||||
|
|
||||||
// list of allowed filenames for the supercharger BIOS.
|
// list of allowed filenames for the supercharger BIOS.
|
||||||
|
@ -75,7 +75,7 @@ func loadBIOS(path string) ([]uint8, error) {
|
||||||
|
|
||||||
// the emulator's resource path
|
// the emulator's resource path
|
||||||
for _, b := range biosFile {
|
for _, b := range biosFile {
|
||||||
p, err := paths.ResourcePath(b)
|
p, err := resources.JoinPath(b)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,8 @@ import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/jetsetilly/gopher2600/paths"
|
|
||||||
"github.com/jetsetilly/gopher2600/prefs"
|
"github.com/jetsetilly/gopher2600/prefs"
|
||||||
|
"github.com/jetsetilly/gopher2600/resources"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Preferences defines and collates all the preference values used by the debugger.
|
// Preferences defines and collates all the preference values used by the debugger.
|
||||||
|
@ -83,7 +83,7 @@ func NewPreferences() (*Preferences, error) {
|
||||||
p.SetDefaults()
|
p.SetDefaults()
|
||||||
|
|
||||||
// setup preferences and load from disk
|
// setup preferences and load from disk
|
||||||
pth, err := paths.ResourcePath(prefs.DefaultPrefsFile)
|
pth, err := resources.JoinPath(prefs.DefaultPrefsFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/jetsetilly/gopher2600/logger"
|
"github.com/jetsetilly/gopher2600/logger"
|
||||||
"github.com/jetsetilly/gopher2600/paths"
|
"github.com/jetsetilly/gopher2600/resources"
|
||||||
)
|
)
|
||||||
|
|
||||||
const saveKeyPath = "savekey"
|
const saveKeyPath = "savekey"
|
||||||
|
@ -60,7 +60,7 @@ func newEeprom() *EEPROM {
|
||||||
|
|
||||||
// Read EEPROM data from disk.
|
// Read EEPROM data from disk.
|
||||||
func (ee *EEPROM) Read() {
|
func (ee *EEPROM) Read() {
|
||||||
fn, err := paths.ResourcePath(saveKeyPath)
|
fn, err := resources.JoinPath(saveKeyPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Logf("savekey", "could not load eeprom file (%s)", err)
|
logger.Logf("savekey", "could not load eeprom file (%s)", err)
|
||||||
return
|
return
|
||||||
|
@ -98,7 +98,7 @@ func (ee *EEPROM) Read() {
|
||||||
|
|
||||||
// Write EEPROM data to disk.
|
// Write EEPROM data to disk.
|
||||||
func (ee *EEPROM) Write() {
|
func (ee *EEPROM) Write() {
|
||||||
fn, err := paths.ResourcePath(saveKeyPath)
|
fn, err := resources.JoinPath(saveKeyPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Logf("savekey", "could not write eeprom file (%s)", err)
|
logger.Logf("savekey", "could not write eeprom file (%s)", err)
|
||||||
return
|
return
|
||||||
|
|
|
@ -17,8 +17,8 @@ package revision
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/jetsetilly/gopher2600/curated"
|
"github.com/jetsetilly/gopher2600/curated"
|
||||||
"github.com/jetsetilly/gopher2600/paths"
|
|
||||||
"github.com/jetsetilly/gopher2600/prefs"
|
"github.com/jetsetilly/gopher2600/prefs"
|
||||||
|
"github.com/jetsetilly/gopher2600/resources"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Preferences for TIA revisins. Use the "live" values inside the emulation
|
// Preferences for TIA revisins. Use the "live" values inside the emulation
|
||||||
|
@ -57,7 +57,7 @@ func newPreferences() (*Preferences, error) {
|
||||||
p := &Preferences{}
|
p := &Preferences{}
|
||||||
|
|
||||||
// save server using the prefs package
|
// save server using the prefs package
|
||||||
pth, err := paths.ResourcePath(prefs.DefaultPrefsFile)
|
pth, err := resources.JoinPath(prefs.DefaultPrefsFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, curated.Errorf("revision: %v", err)
|
return nil, curated.Errorf("revision: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,8 @@ package hiscore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/jetsetilly/gopher2600/curated"
|
"github.com/jetsetilly/gopher2600/curated"
|
||||||
"github.com/jetsetilly/gopher2600/paths"
|
|
||||||
"github.com/jetsetilly/gopher2600/prefs"
|
"github.com/jetsetilly/gopher2600/prefs"
|
||||||
|
"github.com/jetsetilly/gopher2600/resources"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Preferences struct {
|
type Preferences struct {
|
||||||
|
@ -37,7 +37,7 @@ func newPreferences() (*Preferences, error) {
|
||||||
p := &Preferences{}
|
p := &Preferences{}
|
||||||
|
|
||||||
// save server using the prefs package
|
// save server using the prefs package
|
||||||
pth, err := paths.ResourcePath(prefs.DefaultPrefsFile)
|
pth, err := resources.JoinPath(prefs.DefaultPrefsFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, curated.Errorf("hiscore: %v", err)
|
return nil, curated.Errorf("hiscore: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ import (
|
||||||
|
|
||||||
"github.com/jetsetilly/gopher2600/curated"
|
"github.com/jetsetilly/gopher2600/curated"
|
||||||
"github.com/jetsetilly/gopher2600/hardware/memory/cartridge"
|
"github.com/jetsetilly/gopher2600/hardware/memory/cartridge"
|
||||||
"github.com/jetsetilly/gopher2600/paths"
|
"github.com/jetsetilly/gopher2600/resources"
|
||||||
)
|
)
|
||||||
|
|
||||||
const patchPath = "patches"
|
const patchPath = "patches"
|
||||||
|
@ -39,7 +39,7 @@ const neoSeparator = ":"
|
||||||
func CartridgeMemory(mem *cartridge.Cartridge, patchFile string) (bool, error) {
|
func CartridgeMemory(mem *cartridge.Cartridge, patchFile string) (bool, error) {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
p, err := paths.ResourcePath(patchPath, patchFile)
|
p, err := resources.JoinPath(patchPath, patchFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, curated.Errorf("patch: %v", err)
|
return false, curated.Errorf("patch: %v", err)
|
||||||
}
|
}
|
||||||
|
|
36
paths/doc.go
36
paths/doc.go
|
@ -1,36 +0,0 @@
|
||||||
// This file is part of Gopher2600.
|
|
||||||
//
|
|
||||||
// Gopher2600 is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU General Public License as published by
|
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// Gopher2600 is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with Gopher2600. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
// Package paths contains functions to prepare paths for gopher2600 resources.
|
|
||||||
//
|
|
||||||
// The ResourcePath() function returns the correct path to the resource
|
|
||||||
// directory/file specified in the arguments. The result of ResourcePath
|
|
||||||
// depends on the build tag used to compile the program.
|
|
||||||
//
|
|
||||||
// For "release" tagged builds, the correct path is one rooted in the user's
|
|
||||||
// configuration directory. On modern Linux systems the full path would be
|
|
||||||
// something like:
|
|
||||||
//
|
|
||||||
// /home/user/.config/gopher2600/
|
|
||||||
//
|
|
||||||
// For "non-release" tagged builds, the correct path is rooted in the current
|
|
||||||
// working directory:
|
|
||||||
//
|
|
||||||
// .gopher2600
|
|
||||||
//
|
|
||||||
// The reason for this is simple. During development, it is more convenient to
|
|
||||||
// have the config directory close to hand. For release binaries meanwhile, the
|
|
||||||
// config directory should be somewhere the user expects.
|
|
||||||
package paths
|
|
|
@ -36,8 +36,8 @@ import (
|
||||||
"github.com/jetsetilly/gopher2600/hiscore"
|
"github.com/jetsetilly/gopher2600/hiscore"
|
||||||
"github.com/jetsetilly/gopher2600/logger"
|
"github.com/jetsetilly/gopher2600/logger"
|
||||||
"github.com/jetsetilly/gopher2600/patch"
|
"github.com/jetsetilly/gopher2600/patch"
|
||||||
"github.com/jetsetilly/gopher2600/paths"
|
|
||||||
"github.com/jetsetilly/gopher2600/recorder"
|
"github.com/jetsetilly/gopher2600/recorder"
|
||||||
|
"github.com/jetsetilly/gopher2600/resources/unique"
|
||||||
"github.com/jetsetilly/gopher2600/setup"
|
"github.com/jetsetilly/gopher2600/setup"
|
||||||
"github.com/jetsetilly/gopher2600/userinput"
|
"github.com/jetsetilly/gopher2600/userinput"
|
||||||
)
|
)
|
||||||
|
@ -202,7 +202,7 @@ func Play(tv *television.Television, scr gui.GUI, newRecording bool, cartload ca
|
||||||
// new recording requested
|
// new recording requested
|
||||||
|
|
||||||
// create a unique filename
|
// create a unique filename
|
||||||
recording = paths.UniqueFilename("recording", cartload.ShortName())
|
recording = unique.Filename("recording", cartload.ShortName())
|
||||||
|
|
||||||
// prepare new recording
|
// prepare new recording
|
||||||
rec, err := recorder.NewRecorder(recording, vcs)
|
rec, err := recorder.NewRecorder(recording, vcs)
|
||||||
|
|
|
@ -24,7 +24,7 @@ import (
|
||||||
"unicode"
|
"unicode"
|
||||||
|
|
||||||
"github.com/jetsetilly/gopher2600/curated"
|
"github.com/jetsetilly/gopher2600/curated"
|
||||||
"github.com/jetsetilly/gopher2600/paths/fs"
|
"github.com/jetsetilly/gopher2600/resources/fs"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DefaultPrefsFile is the default filename of the global preferences file.
|
// DefaultPrefsFile is the default filename of the global preferences file.
|
||||||
|
|
|
@ -21,9 +21,9 @@
|
||||||
//
|
//
|
||||||
// The Disk type is the key resource in the package. First, create new Disk
|
// The Disk type is the key resource in the package. First, create new Disk
|
||||||
// instance with NewDisk(), specifying the location of the preferences file
|
// instance with NewDisk(), specifying the location of the preferences file
|
||||||
// (using paths.ResourcePath() as necessary).
|
// (using resources.ResourcePath() as necessary).
|
||||||
//
|
//
|
||||||
// fn, _ := paths.ResourcePath(prefs.DefaultPrefsFile)
|
// fn, _ := resources.ResourcePath(prefs.DefaultPrefsFile)
|
||||||
// prf := prefs.NewDisk(fn)
|
// prf := prefs.NewDisk(fn)
|
||||||
//
|
//
|
||||||
// Preference value can then be added with the Add() function, specifying the
|
// Preference value can then be added with the Add() function, specifying the
|
||||||
|
|
|
@ -190,7 +190,7 @@ func (reg *PlaybackRegression) regress(newRegression bool, output io.Writer, msg
|
||||||
// regressionScripts directory
|
// regressionScripts directory
|
||||||
if newRegression {
|
if newRegression {
|
||||||
// create a unique filename
|
// create a unique filename
|
||||||
newScript, err := uniqueFilename("playback", plb.CartLoad)
|
newScript, err := uniqueFilename("playback", plb.CartLoad.ShortName())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, "", curated.Errorf("playback: %v", err)
|
return false, "", curated.Errorf("playback: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,14 +25,14 @@ import (
|
||||||
|
|
||||||
"github.com/jetsetilly/gopher2600/curated"
|
"github.com/jetsetilly/gopher2600/curated"
|
||||||
"github.com/jetsetilly/gopher2600/database"
|
"github.com/jetsetilly/gopher2600/database"
|
||||||
"github.com/jetsetilly/gopher2600/paths"
|
"github.com/jetsetilly/gopher2600/resources"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ansi code for clear line.
|
// ansi code for clear line.
|
||||||
const ansiClearLine = "\033[2K"
|
const ansiClearLine = "\033[2K"
|
||||||
|
|
||||||
// the location of the regressionDB file and the location of any regression
|
// the location of the regressionDB file and the location of any regression
|
||||||
// scripts. these should be wrapped by paths.ResourcePath().
|
// scripts. these should be wrapped by resources.ResourcePath().
|
||||||
const regressionPath = "regression"
|
const regressionPath = "regression"
|
||||||
const regressionDBFile = "db"
|
const regressionDBFile = "db"
|
||||||
const regressionScripts = "scripts"
|
const regressionScripts = "scripts"
|
||||||
|
@ -76,7 +76,7 @@ func RegressList(output io.Writer) error {
|
||||||
return curated.Errorf("regression: list: io.Writer should not be nil (use a nopWriter)")
|
return curated.Errorf("regression: list: io.Writer should not be nil (use a nopWriter)")
|
||||||
}
|
}
|
||||||
|
|
||||||
dbPth, err := paths.ResourcePath(regressionPath, regressionDBFile)
|
dbPth, err := resources.JoinPath(regressionPath, regressionDBFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return curated.Errorf("regression: list: %v", err)
|
return curated.Errorf("regression: list: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ func RegressAdd(output io.Writer, reg Regressor) error {
|
||||||
return curated.Errorf("regression: add: io.Writer should not be nil (use a nopWriter)")
|
return curated.Errorf("regression: add: io.Writer should not be nil (use a nopWriter)")
|
||||||
}
|
}
|
||||||
|
|
||||||
dbPth, err := paths.ResourcePath(regressionPath, regressionDBFile)
|
dbPth, err := resources.JoinPath(regressionPath, regressionDBFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return curated.Errorf("regression: add: %v", err)
|
return curated.Errorf("regression: add: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ func RegressRedux(output io.Writer, confirmation io.Reader) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
dbPth, err := paths.ResourcePath(regressionPath, regressionDBFile)
|
dbPth, err := resources.JoinPath(regressionPath, regressionDBFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return curated.Errorf("regression: redux: %v", err)
|
return curated.Errorf("regression: redux: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -219,7 +219,7 @@ func RegressCleanup(output io.Writer, confirmation io.Reader) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
dbPth, err := paths.ResourcePath(regressionPath, regressionDBFile)
|
dbPth, err := resources.JoinPath(regressionPath, regressionDBFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return curated.Errorf("regression: cleanup: %v", err)
|
return curated.Errorf("regression: cleanup: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -257,7 +257,7 @@ func RegressCleanup(output io.Writer, confirmation io.Reader) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// gather list of files on disk in path
|
// gather list of files on disk in path
|
||||||
scriptPth, err := paths.ResourcePath(regressionPath, regressionScripts)
|
scriptPth, err := resources.JoinPath(regressionPath, regressionScripts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return curated.Errorf("regression: list: %v", err)
|
return curated.Errorf("regression: list: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -281,7 +281,7 @@ func RegressCleanup(output io.Writer, confirmation io.Reader) error {
|
||||||
for _, e := range filesOnDisk {
|
for _, e := range filesOnDisk {
|
||||||
found := false
|
found := false
|
||||||
|
|
||||||
n, err := paths.ResourcePath(regressionPath, regressionScripts, e.Name())
|
n, err := resources.JoinPath(regressionPath, regressionScripts, e.Name())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return curated.Errorf("regression: cleanup: %v", err)
|
return curated.Errorf("regression: cleanup: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -333,7 +333,7 @@ func RegressDelete(output io.Writer, confirmation io.Reader, key string) error {
|
||||||
return curated.Errorf("regression: delete: invalid key [%s]", key)
|
return curated.Errorf("regression: delete: invalid key [%s]", key)
|
||||||
}
|
}
|
||||||
|
|
||||||
dbPth, err := paths.ResourcePath(regressionPath, regressionDBFile)
|
dbPth, err := resources.JoinPath(regressionPath, regressionDBFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return curated.Errorf("regression: delete: %v", err)
|
return curated.Errorf("regression: delete: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -369,7 +369,7 @@ func RegressRun(output io.Writer, verbose bool, filterKeys []string) error {
|
||||||
return curated.Errorf("regression: run: io.Writer should not be nil (use a nopWriter)")
|
return curated.Errorf("regression: run: io.Writer should not be nil (use a nopWriter)")
|
||||||
}
|
}
|
||||||
|
|
||||||
dbPth, err := paths.ResourcePath(regressionPath, regressionDBFile)
|
dbPth, err := resources.JoinPath(regressionPath, regressionDBFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return curated.Errorf("regression: run: %v", err)
|
return curated.Errorf("regression: run: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,25 +16,27 @@
|
||||||
package regression
|
package regression
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/jetsetilly/gopher2600/cartridgeloader"
|
"github.com/jetsetilly/gopher2600/resources"
|
||||||
"github.com/jetsetilly/gopher2600/paths"
|
"github.com/jetsetilly/gopher2600/resources/unique"
|
||||||
)
|
)
|
||||||
|
|
||||||
// create a unique filename from a CatridgeLoader instance. used when saving
|
// uniqueFilename is a shim function for unique.Filename().
|
||||||
|
//
|
||||||
|
// It create a unique filename from a CatridgeLoader instance. used when saving
|
||||||
// scripts into regressionScripts directory. calls paths.UniqueFilename() to
|
// scripts into regressionScripts directory. calls paths.UniqueFilename() to
|
||||||
// maintain common formatting used in the project.
|
// maintain common formatting used in the project.
|
||||||
func uniqueFilename(prepend string, cartload cartridgeloader.Loader) (string, error) {
|
func uniqueFilename(filetype string, cartname string) (string, error) {
|
||||||
f := paths.UniqueFilename(prepend, cartload.ShortName())
|
f := unique.Filename(filetype, cartname)
|
||||||
|
|
||||||
scriptsPath, err := paths.ResourcePath(regressionPath, regressionScripts)
|
scriptsPath, err := resources.JoinPath(regressionPath, regressionScripts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
scrPth, err := paths.ResourcePath(scriptsPath, f)
|
p, err := resources.JoinPath(scriptsPath, f)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
return scrPth, nil
|
return p, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -269,7 +269,7 @@ func (reg *VideoRegression) regress(newRegression bool, output io.Writer, msg st
|
||||||
|
|
||||||
if reg.State != StateNone {
|
if reg.State != StateNone {
|
||||||
// create a unique filename
|
// create a unique filename
|
||||||
reg.stateFile, err = uniqueFilename("state", reg.CartLoad)
|
reg.stateFile, err = uniqueFilename("state", reg.CartLoad.ShortName())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, "", curated.Errorf("video: %v", err)
|
return false, "", curated.Errorf("video: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
//go:build !release
|
//go:build !release
|
||||||
// +build !release
|
// +build !release
|
||||||
|
|
||||||
package paths
|
package resources
|
||||||
|
|
||||||
const gopherConfigDir = ".gopher2600"
|
const gopherConfigDir = ".gopher2600"
|
||||||
|
|
40
resources/doc.go
Normal file
40
resources/doc.go
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
// This file is part of Gopher2600.
|
||||||
|
//
|
||||||
|
// Gopher2600 is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Gopher2600 is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Gopher2600. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
// Package resources contains functions to prepare paths for gopher2600
|
||||||
|
// resources.
|
||||||
|
//
|
||||||
|
// The JoinPath() function returns the correct path to the resource
|
||||||
|
// directory/file specified in the arguments. It handles the creation of
|
||||||
|
// directories as required but does not otherwise touch or create files.
|
||||||
|
//
|
||||||
|
// JoinPath() handles the inclusion of the correct base path. The base path
|
||||||
|
// depends on how the binary was built.
|
||||||
|
//
|
||||||
|
// For builds with the "releas" build tag, the path returned by JoinPath() is
|
||||||
|
// rooted in the user's configuration directory. On modern Linux systems the
|
||||||
|
// full path would be something like:
|
||||||
|
//
|
||||||
|
// /home/user/.config/gopher2600/
|
||||||
|
//
|
||||||
|
// For non-"release" builds, the correct path is rooted in the current working
|
||||||
|
// directory:
|
||||||
|
//
|
||||||
|
// .gopher2600
|
||||||
|
//
|
||||||
|
// The package does this because during development it is more convenient to
|
||||||
|
// have the config directory close to hand. For release binaries however, the
|
||||||
|
// config directory should be somewhere the end-user expects.
|
||||||
|
package resources
|
|
@ -13,21 +13,21 @@
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Gopher2600. If not, see <https://www.gnu.org/licenses/>.
|
// along with Gopher2600. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
package paths
|
package resources
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/jetsetilly/gopher2600/paths/fs"
|
"github.com/jetsetilly/gopher2600/resources/fs"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ResourcePath prepends the supplied path with a with OS/build specific base
|
// JoinPath prepends the supplied path with a with OS/build specific base
|
||||||
// paths
|
// paths
|
||||||
//
|
//
|
||||||
// The function creates all folders necessary to reach the end of sub-path. It
|
// The function creates all folders necessary to reach the end of sub-path. It
|
||||||
// does not otherwise touch or create the file.
|
// does not otherwise touch or create the file.
|
||||||
func ResourcePath(path ...string) (string, error) {
|
func JoinPath(path ...string) (string, error) {
|
||||||
b, err := baseResourcePath()
|
b, err := baseResourcePath()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
|
@ -16,7 +16,7 @@
|
||||||
//go:build release
|
//go:build release
|
||||||
// +build release
|
// +build release
|
||||||
|
|
||||||
package paths
|
package resources
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
|
@ -13,51 +13,33 @@
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Gopher2600. If not, see <https://www.gnu.org/licenses/>.
|
// along with Gopher2600. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
package paths_test
|
package resources_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/jetsetilly/gopher2600/paths"
|
"github.com/jetsetilly/gopher2600/resources"
|
||||||
"github.com/jetsetilly/gopher2600/test"
|
"github.com/jetsetilly/gopher2600/test"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestResourcePath(t *testing.T) {
|
func TestJoinPath(t *testing.T) {
|
||||||
pth, err := paths.ResourcePath("foo/bar", "baz")
|
pth, err := resources.JoinPath("foo/bar", "baz")
|
||||||
test.Equate(t, err, nil)
|
test.Equate(t, err, nil)
|
||||||
test.Equate(t, pth, ".gopher2600/foo/bar/baz")
|
test.Equate(t, pth, ".gopher2600/foo/bar/baz")
|
||||||
|
|
||||||
pth, err = paths.ResourcePath("foo/bar", "")
|
pth, err = resources.JoinPath("foo", "bar", "baz")
|
||||||
|
test.Equate(t, err, nil)
|
||||||
|
test.Equate(t, pth, ".gopher2600/foo/bar/baz")
|
||||||
|
|
||||||
|
pth, err = resources.JoinPath("foo/bar", "")
|
||||||
test.Equate(t, err, nil)
|
test.Equate(t, err, nil)
|
||||||
test.Equate(t, pth, ".gopher2600/foo/bar")
|
test.Equate(t, pth, ".gopher2600/foo/bar")
|
||||||
|
|
||||||
pth, err = paths.ResourcePath("", "baz")
|
pth, err = resources.JoinPath("", "baz")
|
||||||
test.Equate(t, err, nil)
|
test.Equate(t, err, nil)
|
||||||
test.Equate(t, pth, ".gopher2600/baz")
|
test.Equate(t, pth, ".gopher2600/baz")
|
||||||
|
|
||||||
pth, err = paths.ResourcePath("", "")
|
pth, err = resources.JoinPath("", "")
|
||||||
test.Equate(t, err, nil)
|
|
||||||
test.Equate(t, pth, ".gopher2600")
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestResourceFile(t *testing.T) {
|
|
||||||
pth, err := paths.ResourcePath("foo/bar", "baz")
|
|
||||||
test.Equate(t, err, nil)
|
|
||||||
test.Equate(t, pth, ".gopher2600/foo/bar/baz")
|
|
||||||
|
|
||||||
pth, err = paths.ResourcePath("foo", "bar", "baz")
|
|
||||||
test.Equate(t, err, nil)
|
|
||||||
test.Equate(t, pth, ".gopher2600/foo/bar/baz")
|
|
||||||
|
|
||||||
pth, err = paths.ResourcePath("foo/bar", "")
|
|
||||||
test.Equate(t, err, nil)
|
|
||||||
test.Equate(t, pth, ".gopher2600/foo/bar")
|
|
||||||
|
|
||||||
pth, err = paths.ResourcePath("", "baz")
|
|
||||||
test.Equate(t, err, nil)
|
|
||||||
test.Equate(t, pth, ".gopher2600/baz")
|
|
||||||
|
|
||||||
pth, err = paths.ResourcePath("", "")
|
|
||||||
test.Equate(t, err, nil)
|
test.Equate(t, err, nil)
|
||||||
test.Equate(t, pth, ".gopher2600")
|
test.Equate(t, pth, ".gopher2600")
|
||||||
}
|
}
|
22
resources/unique/doc.go
Normal file
22
resources/unique/doc.go
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
// This file is part of Gopher2600.
|
||||||
|
//
|
||||||
|
// Gopher2600 is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Gopher2600 is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Gopher2600. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
// Package unique contains functions that compose filenames that should be
|
||||||
|
// unique on the filesystem.
|
||||||
|
//
|
||||||
|
// This is useful in other Gopher2600 packages. For example, it used to
|
||||||
|
// generate filenames for: playback recordings, regression scripts and many
|
||||||
|
// other file types.
|
||||||
|
package unique
|
|
@ -13,7 +13,7 @@
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Gopher2600. If not, see <https://www.gnu.org/licenses/>.
|
// along with Gopher2600. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
package paths
|
package unique
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -21,34 +21,33 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// UniqueFilename creates a filename that (assuming a functioning clock) should
|
// Filename creates a filename that (assuming a functioning clock) should not
|
||||||
// not collide with any existing file. Note that the function does not test for
|
// collide with any existing file. Note that the function does not test for
|
||||||
// this.
|
// this.
|
||||||
//
|
//
|
||||||
// Used to generate filenames for:
|
|
||||||
// - playback recordings
|
|
||||||
// - regression scripts
|
|
||||||
// - terminal output (sdlimgui GUI)
|
|
||||||
//
|
|
||||||
// Format of returned string is:
|
// Format of returned string is:
|
||||||
//
|
//
|
||||||
// prepend_cartname_YYYYMMDD_HHMMSS
|
// filetype_cartname_YYYYMMDD_HHMMSS
|
||||||
//
|
//
|
||||||
// Where cartname is the string returned by cartload.ShortName(). If there is
|
// Where cartname is the string returned by cartload.ShortName(). If there is
|
||||||
// no cartridge name the returned string will be of the format:
|
// no cartridge name the returned string will be of the format:
|
||||||
//
|
//
|
||||||
// prepend_YYYYMMDD_HHMMSS
|
// filetype_YYYYMMDD_HHMMSS
|
||||||
func UniqueFilename(prepend string, shortCartName string) string {
|
//
|
||||||
|
// The filetype argument is simply another way of identifying the file
|
||||||
|
// uniquely. For example, if saving a screenshot the filetype might simply be
|
||||||
|
// "screenshot" or "photo".
|
||||||
|
func Filename(filetype string, cartName string) string {
|
||||||
n := time.Now()
|
n := time.Now()
|
||||||
timestamp := fmt.Sprintf("%04d%02d%02d_%02d%02d%02d", n.Year(), n.Month(), n.Day(), n.Hour(), n.Minute(), n.Second())
|
timestamp := fmt.Sprintf("%04d%02d%02d_%02d%02d%02d", n.Year(), n.Month(), n.Day(), n.Hour(), n.Minute(), n.Second())
|
||||||
|
|
||||||
var fn string
|
var fn string
|
||||||
|
|
||||||
c := strings.TrimSpace(shortCartName)
|
c := strings.TrimSpace(cartName)
|
||||||
if len(c) > 0 {
|
if len(c) > 0 {
|
||||||
fn = fmt.Sprintf("%s_%s_%s", prepend, c, timestamp)
|
fn = fmt.Sprintf("%s_%s_%s", filetype, c, timestamp)
|
||||||
} else {
|
} else {
|
||||||
fn = fmt.Sprintf("%s_%s", prepend, timestamp)
|
fn = fmt.Sprintf("%s_%s", filetype, timestamp)
|
||||||
}
|
}
|
||||||
|
|
||||||
return fn
|
return fn
|
|
@ -16,8 +16,8 @@
|
||||||
package rewind
|
package rewind
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/jetsetilly/gopher2600/paths"
|
|
||||||
"github.com/jetsetilly/gopher2600/prefs"
|
"github.com/jetsetilly/gopher2600/prefs"
|
||||||
|
"github.com/jetsetilly/gopher2600/resources"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Preferences struct {
|
type Preferences struct {
|
||||||
|
@ -50,7 +50,7 @@ func newPreferences(r *Rewind) (*Preferences, error) {
|
||||||
p.Freq.Set(snapshotFreq)
|
p.Freq.Set(snapshotFreq)
|
||||||
|
|
||||||
// save server using the prefs package
|
// save server using the prefs package
|
||||||
pth, err := paths.ResourcePath(prefs.DefaultPrefsFile)
|
pth, err := resources.JoinPath(prefs.DefaultPrefsFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ import (
|
||||||
"github.com/jetsetilly/gopher2600/curated"
|
"github.com/jetsetilly/gopher2600/curated"
|
||||||
"github.com/jetsetilly/gopher2600/database"
|
"github.com/jetsetilly/gopher2600/database"
|
||||||
"github.com/jetsetilly/gopher2600/hardware"
|
"github.com/jetsetilly/gopher2600/hardware"
|
||||||
"github.com/jetsetilly/gopher2600/paths"
|
"github.com/jetsetilly/gopher2600/resources"
|
||||||
)
|
)
|
||||||
|
|
||||||
// the location of the setupDB file.
|
// the location of the setupDB file.
|
||||||
|
@ -65,7 +65,7 @@ func AttachCartridge(vcs *hardware.VCS, cartload cartridgeloader.Loader) error {
|
||||||
return curated.Errorf("setup: %v", err)
|
return curated.Errorf("setup: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
dbPth, err := paths.ResourcePath(setupDBFile)
|
dbPth, err := resources.JoinPath(setupDBFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return curated.Errorf("setup: %v", err)
|
return curated.Errorf("setup: %v", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue