mirror of
https://github.com/RetroDECK/RetroDECK.git
synced 2024-11-22 05:55:38 +00:00
Add CHD compression argument and functions
This commit is contained in:
parent
cc04b9ff59
commit
fb3b96b642
43
functions.sh
43
functions.sh
|
@ -86,6 +86,49 @@ move() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
compress_to_chd () {
|
||||||
|
# Function for compressing one or more files to .chd format
|
||||||
|
# USAGE: compress_to_chd $full_path_to_input_file $full_path_to_output_file
|
||||||
|
|
||||||
|
echo "Compressing file $1 to $2.chd"
|
||||||
|
/app/bin/chdman createcd -i $1 -o $2.chd
|
||||||
|
}
|
||||||
|
|
||||||
|
validate_for_chd () {
|
||||||
|
# Function for validating chd compression candidates, and compresses if validation passes. Supports .cue, .iso and .gdi formats ONLY
|
||||||
|
# USAGE: validate_for_chd $input_file
|
||||||
|
|
||||||
|
local file=$1
|
||||||
|
if [[ "$file" == *".cue" ]] || [[ "$file" == *".gdi" ]] || [[ "$file" == *".iso" ]]; then
|
||||||
|
echo ".cue/.iso/.gdi file detected"
|
||||||
|
local file_path=$(dirname $(realpath $file))
|
||||||
|
local file_base_name=$(basename $file)
|
||||||
|
local file_name=${file_base_name%.*}
|
||||||
|
if [[ "$file" == *".cue" ]]; then # Validate .cue file correctly maps existing .bin file(s)
|
||||||
|
local cue_bin_files=$(grep -o -P "(?<=FILE \").*(?=\".*$)" $file)
|
||||||
|
local cue_validated="false"
|
||||||
|
for line in $cue_bin_files
|
||||||
|
do
|
||||||
|
if [[ -f "$file_path/$line" ]]; then
|
||||||
|
cue_validated="true"
|
||||||
|
else
|
||||||
|
echo ".bin file NOT found at $file_path/$line"
|
||||||
|
echo ".cue file could not be validated. Please verify your .cue file contains the correct corresponding .bin file information and retry."
|
||||||
|
cue_validated="false"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [[ $cue_validated == "true" ]]; then
|
||||||
|
compress_to_chd "$file_path/$file_base_name" "$file_path/$file_name"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
compress_to_chd "$file_path/$file_base_name" "$file_path/$file_name"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "File type not recognized. Supported file types are .cue, .gdi and .iso"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
set_setting_value() {
|
set_setting_value() {
|
||||||
# Function for editing settings
|
# Function for editing settings
|
||||||
# USAGE: set_setting_value $setting_file "$setting_name" "$new_setting_value" $system $section_name(optional)
|
# USAGE: set_setting_value $setting_file "$setting_name" "$new_setting_value" $system $section_name(optional)
|
||||||
|
|
21
retrodeck.sh
21
retrodeck.sh
|
@ -18,6 +18,7 @@ Arguments:
|
||||||
-v, --version Print RetroDECK version
|
-v, --version Print RetroDECK version
|
||||||
--info-msg Print paths and config informations
|
--info-msg Print paths and config informations
|
||||||
--configure Starts the RetroDECK Configurator
|
--configure Starts the RetroDECK Configurator
|
||||||
|
--compress <file> Compresses target file to .chd format. Supports .cue, .iso and .gdi formats.
|
||||||
--reset-all Starts the initial RetroDECK installer (backup your data first!)
|
--reset-all Starts the initial RetroDECK installer (backup your data first!)
|
||||||
--reset-ra Resets RetroArch's config to the default values
|
--reset-ra Resets RetroArch's config to the default values
|
||||||
--reset-sa Reset all standalone emulator configs to the default values
|
--reset-sa Reset all standalone emulator configs to the default values
|
||||||
|
@ -42,6 +43,22 @@ https://retrodeck.net
|
||||||
cat $rd_conf
|
cat $rd_conf
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
--compress*)
|
||||||
|
if [[ ! -z $2 ]]; then
|
||||||
|
if [[ -f $2 ]]; then
|
||||||
|
validate_for_chd $2
|
||||||
|
else
|
||||||
|
echo "File not found, please specify the full path to the file to be compressed."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Please use this command format \"--compress <full path to cue/gdi/iso file>\""
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--configure*)
|
||||||
|
sh /var/config/retrodeck/tools/configurator.sh
|
||||||
|
shift
|
||||||
|
;;
|
||||||
--reset-ra*)
|
--reset-ra*)
|
||||||
ra_init
|
ra_init
|
||||||
shift # past argument with no value
|
shift # past argument with no value
|
||||||
|
@ -58,10 +75,6 @@ https://retrodeck.net
|
||||||
rm -f "$lockfile"
|
rm -f "$lockfile"
|
||||||
shift # past argument with no value
|
shift # past argument with no value
|
||||||
;;
|
;;
|
||||||
--configure*)
|
|
||||||
sh /var/config/retrodeck/tools/configurator.sh
|
|
||||||
shift # past argument with no value
|
|
||||||
;;
|
|
||||||
-*|--*)
|
-*|--*)
|
||||||
echo "Unknown option $i"
|
echo "Unknown option $i"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
Loading…
Reference in a new issue