"Uncompressed XML Files" format variants

Jos van den Oever jos.van.den.oever at kogmbh.com
Mon Nov 12 21:00:09 GMT 2012


On 11/12/2012 09:56 PM, Friedrich W. H. Kossebau wrote:
> Am Montag, 12. November 2012, 17:10:09 schrieb Inge Wallin:
>> Would you go for disable saving and still allow loading? That way you won't
>> destroy for those few that actually have uncompressed odf files out there.
>
> Hm, what about a small script instead which transforms the uncompressed files
> into a fod* or od* instead?

Here you go.





-------------- next part --------------
#! /bin/bash

DIR=${1%/}
OUTPUT=$2

if [ ! -d "$DIR" ]; then
	echo "Provide a directory to pack."
	exit 1
fi
if [ -z "$OUTPUT" ]; then
	BASE=${DIR%_*}
	EXT=${DIR##*_}
	if [ "${BASE}_$EXT" != "$DIR" ]; then
		echo "Provide output name or use directory like 'name_ext'."
		exit 1
	fi
	OUTPUT="$BASE.$EXT"
fi
if [ ${OUTPUT:0:1} != "/" ]; then
	OUTPUT="$PWD/$OUTPUT"
fi

if [ ! -f "$DIR/mimetype" ]; then
	echo "No mimetype file present."
	exit 1
fi
if [ ! -f "$DIR/content.xml" ]; then
	echo "No content.xml file present."
	exit 1
fi
if [ ! -f "$DIR/styles.xml" ]; then
	echo "No styles.xml file present."
	exit 1
fi
if [ -f "$OUTPUT" ]; then
	rm "$OUTPUT"
fi

cd "$DIR"
zip -D -X -0 "$OUTPUT" mimetype
zip -D -X -9 -r "$OUTPUT" . -x mimetype \*/.\* .\* \*.png \*.jpg \*.jpeg
zip -D -X -0 -r "$OUTPUT" . -i \*.png \*.jpg \*.jpeg
echo Created "$OUTPUT"


More information about the calligra-devel mailing list