[Scummvm-git-logs] scummvm master -> 4c600372357dc9e83655efcf694df409558b36d6

sev- sev at scummvm.org
Sat Aug 1 12:30:34 UTC 2020


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
4c60037235 DEVTOOLS: Added hfsutils mode for encode-macbinary.sh


Commit: 4c600372357dc9e83655efcf694df409558b36d6
    https://github.com/scummvm/scummvm/commit/4c600372357dc9e83655efcf694df409558b36d6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-08-01T14:30:10+02:00

Commit Message:
DEVTOOLS: Added hfsutils mode for encode-macbinary.sh

Changed paths:
    devtools/encode-macbinary.sh


diff --git a/devtools/encode-macbinary.sh b/devtools/encode-macbinary.sh
index 0655fc9242..e9465c10d7 100755
--- a/devtools/encode-macbinary.sh
+++ b/devtools/encode-macbinary.sh
@@ -1,25 +1,141 @@
 #!/bin/bash
-#
-# Iterates over current directory, encodes all files with
-# MacBinary but ensures that the dates are preserved
-
-for i in *
-do
-	if test -d "$i" ; then
-		cd "$i"
-		if [ "$(ls -A .)" ] ; then # directory is not empty
-			bash $0 "$1/$i"
+
+usage() {
+			cat << EOF
+Usage: $0 [OPTIONS]...
+
+Dumping Mac files into MacBinary format
+
+There are 2 operation modes. Direct MacBinary encoding (Mac-only) and dumping ISO
+contents with hfsutils.
+
+Mode 1:
+  $0 macbinary
+      Operate in MacBinary encoding mode
+
+Mode 2:
+  $0 <file.iso>
+      Operate in disk dumping mode
+
+Miscellaneous:
+  -h, --help   display this help and exit
+EOF
+}
+
+path=
+
+macbinarydump() {
+	mypath=`realpath $0`
+
+	for i in *
+	do
+		if test -d "$i" ; then
+			cd "$i"
+			if [ "$(ls -A .)" ] ; then # directory is not empty
+				bash $mypath macbinary-phase2 "$path/$i"
+			fi
+			cd ..
+		else
+			echo -ne "$path/$i...                 \r"
+			macbinary encode "$i"
+			touch -r "$i" "$i.bin"
+			mv "$i.bin" "$i"
+		fi
+	done
+}
+
+hfsdump() {
+	IFS=$'\n'
+	mypath=`realpath $0`
+
+	for i in `hls -F1a`
+	do
+		if [[ "$i" =~ ":" ]] ; then
+			dir="${i%?}"
+			hcd "$dir"
+			mkdir "$dir"
+			cd "$dir"
+			bash $mypath hfsutils-phase2 "$path:$i"
+			hcd ::
+			cd ..
+		else
+			echo -ne "$path$i...                 \r"
+			# Executable files have star at their end. Strip it
+			if [[ "$i" =~ \*$ ]] ; then
+				file="${i%?}"
+			else
+				file="$i"
+			fi
+			fileunix="$file"
+			# Files count contain stars
+			file="${file//\*/\\*}"
+			hcopy -m "$file" "./$fileunix"
 		fi
-		cd ..
-	else
-		echo -ne "$1/$i...                 \r"
-		macbinary encode "$i"
-		touch -r "$i" "$i.bin"
-		mv "$i.bin" "$i"
+	done
+}
+
+for parm in "$@" ; do
+	if test "$parm" = "--help" || test "$parm" = "-help" || test "$parm" = "-h" ; then
+		usage
+		exit 0
 	fi
-done
+done  # for parm in ...
 
-# on the top level we want to print a new line
-if test -z "$1" ; then
+if [[ $1 == "macbinary" ]] ; then
+	if test ! `type macbinary >/dev/null 2>/dev/null` ; then
+		echo "macbinary not found. Exiting"
+		exit 1
+	fi
+	macbinarydump
 	echo
+	exit 0
+fi
+
+if [[ $1 == "macbinary-phase2" ]] ; then
+	path=$2
+	macbinarydump
+	exit 0
 fi
+
+###########
+# hfsutils mode
+if  [ "$#" -lt 1 ] ; then
+	usage
+	exit 1
+fi
+
+if [[ $1 == "hfsutils-phase2" ]] ; then
+	path=$2
+	hfsdump
+	exit 0
+fi
+
+if ! `type hmount >/dev/null 2>/dev/null` ; then
+	echo "hfsutils not found. Exiting"
+	exit 1
+fi
+
+isofile="$1"
+
+echo -n "Mounting ISO..."
+hmount "$isofile" >/dev/null 2>/dev/null
+if test -z $? ; then
+	echo error
+	exit 1
+fi
+
+echo done
+
+echo "Dumping..."
+
+hfsdump
+echo
+
+echo -n "Unmounting ISO..."
+humount >/dev/null 2>/dev/null
+if test -z $? ; then
+	echo error
+	exit 1
+fi
+
+echo done




More information about the Scummvm-git-logs mailing list