mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-21 10:20:21 +00:00
f1da4e8fb0
removed tmprom and uses tmpdir/filename instead.
82 lines
1.8 KiB
Bash
Executable File
82 lines
1.8 KiB
Bash
Executable File
#!/bin/sh
|
|
###
|
|
## Wrapper script that enables loading of compressed roms for RetroArch.
|
|
## Author: Themaister
|
|
## License: Do whatever you want with it.
|
|
#
|
|
|
|
die()
|
|
{
|
|
echo "Error: $1"
|
|
rm -r "${TMPDIR}"
|
|
exit 1
|
|
}
|
|
|
|
if [ -z "$1" ]; then
|
|
die "Need at least one argument"
|
|
fi
|
|
|
|
COMP_FILE="$1"
|
|
TMPDIR="`mktemp -d`"
|
|
shift
|
|
|
|
extract_zip()
|
|
{
|
|
which unzip >/dev/null 2>&1 || die "Cannot find unzip"
|
|
unzip "$1" -d "${TMPDIR}" >/dev/null 2>&1 || die "Couldn't extract from archive"
|
|
}
|
|
|
|
extract_7z()
|
|
{
|
|
which 7z >/dev/null 2>&1 || die "Cannot find 7z"
|
|
7z x "$1" -o"${TMPDIR}" >/dev/null 2>&1 || die "Couldn't extract from archive"
|
|
}
|
|
|
|
extract_rar()
|
|
{
|
|
which unrar >/dev/null 2>&1 || die "Cannot find unrar"
|
|
unrar x "$1" "${TMPDIR}" >/dev/null 2>&1 || die "Couldn't extract from archive"
|
|
}
|
|
|
|
case "${COMP_FILE}" in
|
|
*.zip )
|
|
extract_zip "${COMP_FILE}"
|
|
EXTENSION=".zip"
|
|
;;
|
|
*.7z )
|
|
extract_7z "${COMP_FILE}"
|
|
EXTENSION=".7z"
|
|
;;
|
|
*.rar )
|
|
extract_rar "${COMP_FILE}"
|
|
EXTENSION=".rar"
|
|
;;
|
|
* )
|
|
die "Couldn't find valid zipped rom."
|
|
;;
|
|
esac
|
|
|
|
# pick the largest non-directory in the root of the unpacked archive
|
|
FILENAME="`ls -Sp \"${TMPDIR}\" | grep -v /$ | head -n1`"
|
|
if [ -z "${FILENAME}" ]; then
|
|
die "Cannot find any files in root of archive"
|
|
fi
|
|
|
|
SAVENAME="`basename \"${COMP_FILE}\" ${EXTENSION}`"
|
|
SAVESTATE="`basename \"${COMP_FILE}\" ${EXTENSION}`"
|
|
DIRNAME="`dirname \"${COMP_FILE}\"`"
|
|
SAVENAME="${SAVENAME}.srm"
|
|
SAVESTATE="${SAVESTATE}.state"
|
|
|
|
EXE="`which retroarch`"
|
|
if [ -z "${EXE}" ]; then
|
|
die "Cannot find RetroArch in path."
|
|
fi
|
|
|
|
echo "Temp ROM: ${TMPDIR}/${FILENAME}"
|
|
echo "Savename: ${DIRNAME}/${SAVENAME}"
|
|
echo "Savestate: ${DIRNAME}/${SAVESTATE}"
|
|
"${EXE}" "${TMPDIR}/${FILENAME}" -s "${DIRNAME}/${SAVENAME}" -S "${DIRNAME}/${SAVESTATE}" "$@"
|
|
rm -r "${TMPDIR}"
|
|
|