mirror of
				https://gitlab.com/octospacc/Snippets.git
				synced 2025-06-27 09:02:56 +02:00 
			
		
		
		
	Upd Ps2EmuVmcConvert after fail Android test
This commit is contained in:
		| @@ -4,23 +4,19 @@ Shell=sh | |||||||
| Script="$(realpath "$0")" | Script="$(realpath "$0")" | ||||||
| ArchiveName=mymc.tar.xz | ArchiveName=mymc.tar.xz | ||||||
|  |  | ||||||
| Ps2VmcPath=/mnt/media_rw/8A3A-912B/VMC/games.bin | Ps2VmcPath=/tmp/Ps2EmuVmcConvert/games.bin | ||||||
| EmuVmcPath=/sdcard/Android/data/xyz.aethersx2.android/files/memcards/games.ps2 | EmuVmcPath=/tmp/Ps2EmuVmcConvert/games.ps2 | ||||||
| TrySuperuser=true | TrySuperuser=false | ||||||
|  |  | ||||||
| # Script assumes shell path contains following commands and programs: | # Script assumes shell path contains following commands and programs: | ||||||
| # sh [ mkdir realpath basename grep cut rev base64 tar xz python2.7 whoami sudo | # sh [ mkdir realpath basename grep cut base64 tar xz python2.7 whoami sudo | ||||||
|  |  | ||||||
| #ArchiveNum=1 |  | ||||||
| #ArchiveLine="$(grep -aFn "#===================[ #${ArchiveNum}: START FILE SECTION \`${ArchiveName}\` ]===================#" "$0" | cut -f1 -d:)" |  | ||||||
| #head -n $((${ArchiveLine}+1)) "$0" | tail -n 1 | base64 -d > "./${ArchiveName}" |  | ||||||
| #===================[ #1: START FILE SECTION `mymc.tar.xz` ]===================# |  | ||||||
|  |  | ||||||
| # Exit when no valid option | # Exit when no valid option | ||||||
| [ "$1" != FromPs2ToEmu ] && [ "$1" != FromEmuToPs2 ] && { echo "Usage: $0 <FromPs2ToEmu|FromEmuToPs2>"; exit; } | [ "$1" != FromPs2ToEmu ] && [ "$1" != FromEmuToPs2 ] && { echo "Usage: $0 <FromPs2ToEmu|FromEmuToPs2>"; exit; } | ||||||
|  |  | ||||||
| # Ensure superuser if necessary | # Ensure superuser if necessary | ||||||
| [ "${TrySuperuser}" = true ] && [ "$(whoami)" != root ] && { sudo "${Shell}" "${Script}" $@; exit; } | [ "${TrySuperuser}" = true ] && [ "$(whoami)" != root ] && { sudo "${Shell}" "${Script}" $@; exit; } | ||||||
|  | SuperDo(){ [ "${TrySuperuser}" = true ] && [ "$(whoami)" != root ] && sudo $@ || $@ ;} | ||||||
|  |  | ||||||
| # Extract mymc to a known reusable directory, if not already present | # Extract mymc to a known reusable directory, if not already present | ||||||
| [ -z "${HOME}" ] && HOME=. | [ -z "${HOME}" ] && HOME=. | ||||||
| @@ -30,7 +26,7 @@ if [ ! -d "${BinDir}/mymc" ] | |||||||
| then | then | ||||||
| 	OWD="${PWD}" | 	OWD="${PWD}" | ||||||
| 	cd "${BinDir}" | 	cd "${BinDir}" | ||||||
| 	grep "# FILE SECTION \`${ArchiveName}\` #" "$0" | cut -f3 -d"#" | cut -b2- | base64 -d | tar xJ | 	grep "# FILE SECTION \`${ArchiveName}\` #" "${Script}" | cut -f3 -d"#" | cut -b2- | base64 -d | tar xJ | ||||||
| 	cd "${OWD}" | 	cd "${OWD}" | ||||||
| fi | fi | ||||||
|  |  | ||||||
| @@ -43,29 +39,39 @@ fi | |||||||
|  |  | ||||||
| # Setup some variables | # Setup some variables | ||||||
| mymc(){ python2.7 "${BinDir}/mymc/mymc.py" --ignore-ecc $@ ;} | mymc(){ python2.7 "${BinDir}/mymc/mymc.py" --ignore-ecc $@ ;} | ||||||
| Ps2VmcPath="$(realpath "${Ps2VmcPath}")" | Ps2VmcPath="$(SuperDo realpath "${Ps2VmcPath}")" | ||||||
| EmuVmcPath="$(realpath "${EmuVmcPath}")" | EmuVmcPath="$(SuperDo realpath "${EmuVmcPath}")" | ||||||
| [ "$1" = FromPs2ToEmu ] && { VmcFromPath="${Ps2VmcPath}"; VmcToPath="${EmuVmcPath}"; } | [ "$1" = FromPs2ToEmu ] && { VmcFromPath="${Ps2VmcPath}"; VmcToPath="${EmuVmcPath}"; } | ||||||
| [ "$1" = FromEmuToPs2 ] && { VmcFromPath="${EmuVmcPath}"; VmcToPath="${Ps2VmcPath}"; } | [ "$1" = FromEmuToPs2 ] && { VmcFromPath="${EmuVmcPath}"; VmcToPath="${Ps2VmcPath}"; } | ||||||
|  |  | ||||||
| # Ensure ready temporary directory and set us there | # Ensure ready temporary directory and set us there | ||||||
| [ -z "${XDG_RUNTIME_DIR}" ] && XDG_RUNTIME_DIR="${HOME}/.local/tmp" | [ -z "${XDG_RUNTIME_DIR}" ] && XDG_RUNTIME_DIR="${HOME}/.local/tmp" | ||||||
| TmpDir="${XDG_RUNTIME_DIR}/Ps2EmuVmcConvert" | TmpDir="${XDG_RUNTIME_DIR}/Ps2EmuVmcConvert" | ||||||
| mkdir -p "${TmpDir}" | rm -rf "${TmpDir}" || true | ||||||
| cd "${TmpDir}" | mkdir -p "${TmpDir}/saves" | ||||||
| rm -f * | cd "${TmpDir}/saves" | ||||||
|  |  | ||||||
| # Save reading, conversion, and writing | # Copy files to act on them locally to avoid Android issues | ||||||
|  | #SuperDo cp "${VmcFromPath}" ../From.vmc | ||||||
|  | #SuperDo chmod +rw ../From.vmc | ||||||
|  | #SuperDo cp "${VmcToPath}" ../To.vmc | ||||||
|  | #SuperDo chmod +rw ../To.vmc | ||||||
|  |  | ||||||
|  | # Saves reading, conversion, and writing | ||||||
|  | #mymc ../From.vmc export "*" | ||||||
| mymc "${VmcFromPath}" export "*" | mymc "${VmcFromPath}" export "*" | ||||||
| for Savefile in *.psu | for Savefile in *.psu | ||||||
| do | do | ||||||
| 	#Savename="$(echo "${i}" | rev | cut -d. -f2- | rev)" |  | ||||||
| 	Savename="$(basename "${Savefile}" .psu)" | 	Savename="$(basename "${Savefile}" .psu)" | ||||||
| 	mv "${Savefile}" "${Savename}" | 	mv "${Savefile}" "${Savename}" | ||||||
| done | done | ||||||
|  | #for Save in *; do { mymc ../To.vmc delete "${Save}" || true ;}; done | ||||||
| for Save in *; do { mymc "${VmcToPath}" delete "${Save}" || true ;}; done | for Save in *; do { mymc "${VmcToPath}" delete "${Save}" || true ;}; done | ||||||
| for Save in *; do mv "${Save}" "${Save}.psu"; done | for Save in *; do mv "${Save}" "${Save}.psu"; done | ||||||
| mymc "${VmcToPath}" import * | mymc "${VmcToPath}" import * | ||||||
|  | #mymc ../To.vmc import * | ||||||
|  | #cat ../To.vmc > "${VmcToPath}" | ||||||
|  | #SuperDo cp ../To.vmc "${VmcToPath}" | ||||||
|  |  | ||||||
| exit | exit | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user