Use local size.sh script with cross-platform support

This commit is contained in:
mmcwilliams 2020-08-25 10:07:33 -04:00
parent 2760cf5fee
commit 2cf56276af
6 changed files with 29 additions and 2 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 77 KiB

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 59 KiB

View File

@ -16,7 +16,7 @@ do
FILES=./stl/${SIZE}_${VERSION}/*.stl
for stl in $FILES
do
fileSize=`wc -c < "$stl"`
fileSize=`bash ./scripts/size.sh "$stl"`
fileSize=`echo $newSize | xargs`
firstline=`head -n 1 "$stl"`
@ -24,7 +24,7 @@ do
echo "Converting $stl to binary..."
#convert from ascii to binary
admesh -c -b "$stl" "$stl"
newSize=`wc -c < "$stl"`
newSize=`bash ./scripts/size.sh "$stl"`
newSize=`echo $newSize | xargs`
percent=`echo "scale=1;($newSize/$fileSize)*100" | bc`
#fileSize="${newSize}"

27
scripts/size.sh Normal file
View File

@ -0,0 +1,27 @@
#!/bin/bash
FILE="$1"
if [ "$FILE" = "" ]; then
echo -1
exit 1
fi
#wc -c < "$FILE"
#exit 0
if [ "$(uname)" == "Darwin" ]; then
# Mac OS X platform
stat -f%z "${FILE}"
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
# GNU/Linux platform
stat -c%s "${FILE}"
elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ]; then
# 32 bits Windows NT platform
echo -1
exit 2
elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW64_NT" ]; then
# 64 bits Windows NT platform
echo -1
exit 3
fi