File tree Expand file tree Collapse file tree 7 files changed +40
-2
lines changed
.github/workflows/cd/cloudretro.io Expand file tree Collapse file tree 7 files changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -29,12 +29,12 @@ emulator:
29
29
logLevel : 1
30
30
cores :
31
31
list :
32
+ dos :
33
+ uniqueSaveDir : true
32
34
mame :
33
35
options :
34
36
" fbneo-diagnostic-input " : " Hold Start"
35
37
nes :
36
38
scale : 2
37
- pcsx :
38
- altRepo : true
39
39
snes :
40
40
scale : 2
Original file line number Diff line number Diff line change @@ -209,6 +209,8 @@ emulator:
209
209
# - skip_hw_context_destroy -- don't destroy OpenGL context during Libretro core deinit.
210
210
# May help with crashes, for example, with PPSSPP.
211
211
# - skip_same_thread_save -- skip thread lock save (used with PPSSPP).
212
+ # - uniqueSaveDir (bool) -- needed only for cores (like DosBox) that persist their state into one shared file.
213
+ # This will allow for concurrent reading and saving of current states.
212
214
list :
213
215
gba :
214
216
lib : mgba_libretro
Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ type LibretroCoreConfig struct {
55
55
Options4rom map [string ]map [string ]string // <(^_^)>
56
56
Roms []string
57
57
Scale float64
58
+ UniqueSaveDir bool
58
59
UsesLibCo bool
59
60
VFR bool
60
61
Width int
Original file line number Diff line number Diff line change @@ -84,3 +84,7 @@ func StatSize(path string) (int64, error) {
84
84
}
85
85
return fi .Size (), nil
86
86
}
87
+
88
+ func RemoveAll (path string ) error {
89
+ return os .RemoveAll (path )
90
+ }
Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ type Frontend struct {
66
66
67
67
DisableCanvasPool bool
68
68
SaveOnClose bool
69
+ UniqueSaveDir bool
69
70
}
70
71
71
72
type Device byte
@@ -153,6 +154,11 @@ func (f *Frontend) LoadCore(emu string) {
153
154
KbMouseSupport : conf .KbMouseSupport ,
154
155
}
155
156
f .mu .Lock ()
157
+ if conf .UniqueSaveDir {
158
+ f .UniqueSaveDir = true
159
+ f .nano .SetSaveDirSuffix (f .storage .MainPath ())
160
+ f .log .Debug ().Msgf ("Using unique dir for saves: %v" , f .storage .MainPath ())
161
+ }
156
162
scale := 1.0
157
163
if conf .Scale > 1 {
158
164
scale = conf .Scale
@@ -336,6 +342,13 @@ func (f *Frontend) Close() {
336
342
337
343
f .mui .Lock ()
338
344
f .nano .Close ()
345
+
346
+ if f .UniqueSaveDir && ! f .HasSave () {
347
+ if err := f .nano .DeleteSaveDir (); err != nil {
348
+ f .log .Error ().Msgf ("couldn't delete save dir: %v" , err )
349
+ }
350
+ }
351
+
339
352
f .mui .Unlock ()
340
353
f .log .Debug ().Msgf ("frontend closed" )
341
354
}
Original file line number Diff line number Diff line change @@ -157,6 +157,22 @@ func (n *Nanoarch) WaitReady() { <-n.reserved }
157
157
func (n * Nanoarch ) Close () { n .Stopped .Store (true ); n .reserved <- struct {}{} }
158
158
func (n * Nanoarch ) SetLogger (log * logger.Logger ) { n .log = log }
159
159
func (n * Nanoarch ) SetVideoDebounce (t time.Duration ) { n .limiter = NewLimit (t ) }
160
+ func (n * Nanoarch ) SetSaveDirSuffix (sx string ) {
161
+ if n .cSaveDirectory != nil {
162
+ C .free (unsafe .Pointer (n .cSaveDirectory ))
163
+ }
164
+ dir := C .GoString (n .cSaveDirectory ) + "/" + sx
165
+ _ = os .CheckCreateDir (dir )
166
+ n .cSaveDirectory = C .CString (dir )
167
+ }
168
+ func (n * Nanoarch ) DeleteSaveDir () error {
169
+ if n .cSaveDirectory == nil {
170
+ return nil
171
+ }
172
+
173
+ dir := C .GoString (n .cSaveDirectory )
174
+ return os .RemoveAll (dir )
175
+ }
160
176
161
177
func (n * Nanoarch ) CoreLoad (meta Metadata ) {
162
178
var err error
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import (
10
10
11
11
type (
12
12
Storage interface {
13
+ MainPath () string
13
14
GetSavePath () string
14
15
GetSRAMPath () string
15
16
SetMainSaveName (name string )
32
33
}
33
34
)
34
35
36
+ func (s * StateStorage ) MainPath () string { return s .MainSave }
35
37
func (s * StateStorage ) SetMainSaveName (name string ) { s .MainSave = name }
36
38
func (s * StateStorage ) SetNonBlocking (v bool ) { s .NonBlock = v }
37
39
func (s * StateStorage ) GetSavePath () string { return filepath .Join (s .Path , s .MainSave + ".dat" ) }
You can’t perform that action at this time.
0 commit comments