Added FileIsEmpty function and small adjustments to other functions

This commit is contained in:
mboelen 2014-09-17 09:59:18 +02:00
parent 6145570c7f
commit 5b0944057b
1 changed files with 22 additions and 4 deletions

View File

@ -29,6 +29,7 @@
# ExitClean Stop the program (cleanly)
# ExitFatal Stop the program (cleanly), with fatal
# FileExists Check if a file exists on the disk
# FileIsEmpty Check if a file is empty
# FileIsReadable Check if a file is readable or directory accessible
# GetHostID Retrieve an unique ID for this host
# InsertSection Insert a section block
@ -143,10 +144,10 @@
DIRECTORY_FOUND=0
logtext "Test: checking if directory $1 exists"
if [ -d $1 ]; then
logtext "Result: directory exists"
logtext "Result: directory $1 exists"
DIRECTORY_FOUND=1
else
logtext "Result: directory NOT found"
logtext "Result: directory $1 NOT found"
fi
}
@ -242,13 +243,30 @@
FILE_FOUND=0
logtext "Test: checking if file $1 exists"
if [ -f $1 ]; then
logtext "Result: file exists"
logtext "Result: file $1 exists"
FILE_FOUND=1
else
logtext "Result: file NOT found"
logtext "Result: file $1 NOT found"
fi
}
################################################################################
# Name : FileIsEmpty
# Description : Check if a file is empty
# Returns : EMPTY (0 or 1)
################################################################################
FileIsEmpty()
{
EMPTY=0
logtext "Test: checking if file $1 is empty"
if [ -z $1 ]; then
logtext "Result: file $1 is empty"
EMPTY=1
else
logtext "Result: file $1 is NOT empty"
fi
}
################################################################################
# Name : FileIsReadable