Explorar el Código

Implemented function to build local save file filters

Eric Ostrowski hace 6 años
padre
commit
46bc415207
Se han modificado 2 ficheros con 52 adiciones y 0 borrados
  1. 13 0
      emulator_settings.xml
  2. 39 0
      rclone_script.sh

+ 13 - 0
emulator_settings.xml

@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<emulators>
+    <emulator>
+        <name>ppsspp</name>
+        <saveFilePath>/opt/retropie/configs/psp/PSP/SAVEDATA</saveFilePath>
+        <saveStatePath>/opt/retropie/configs/psp/PSP/PPSSPP_STATE</saveStatePath>
+        <saveFileExtensions>
+            <ext>SYS</ext>
+            <ext>PNG</ext>
+            <ext>SFO</ext>
+        </saveFileExtensions>
+    </emulator>
+</emulators>

+ 39 - 0
rclone_script.sh

@@ -14,6 +14,9 @@ config=~/scripts/rclone_script/rclone_script.ini
 source ${config}
 logLevel=2
 
+# include emulator specific settings
+emu_settings=~/scripts/rclone_script/emulator_settings.xml
+
 
 # parameters
 direction="$1"
@@ -139,6 +142,41 @@ function prepareFilter ()
 	filter="${filter//\]/\\]}"
 }
 
+# Builds a filter compatible with Find
+function prepareLocalFilter ()
+{
+	# Create an array of save file extensions
+	read -a exts <<< $(xmlstarlet sel -t -m "emulators/emulator[name='${emulator}']/saveFileExtensions" -v . "${emu_settings}")
+
+	# If any custom save file extensions are defined
+	if [ ${#exts[@]} -gt 0 ]
+	then
+		# Build the filter for the extensions
+		log 3 "Custom save extentions defined for emulator: ${emulator}"
+		localFilter="\( -iname '*.${exts[0]}'"
+		for ext in ${exts[@]:1}; do
+			localFilter="${localFilter} -o -iname '*.${ext}'"
+		done
+		localFilter="${localFilter} \)"
+	else
+		# Otherwise, default to "<ROM_name>.*"
+		localFilter="${romfilebase//\[/\\[}"
+		localFilter="${localFilter//\]/\\]}"
+	fi
+
+	log 3 "Local save file filter: ${localFilter}"
+}
+
+function prepareRemoteFilter ()
+{
+
+}
+
+function getSavePathForEmulator ()
+{
+
+}
+
 function getTypeOfRemote ()
 {
 	# list all remotes and their type
@@ -350,6 +388,7 @@ log 3 "romfileext: ${romfileext}"
 if [ "${direction}" == "up" ] && [ "${system}" != "kodi" ]
 then
 	getROMFileName
+	prepareLocalFilter
 	prepareFilter
 	getTypeOfRemote
 	uploadSaves