| #!/bin/bash |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| function cli_checkFiles { |
| |
| local FILE='' |
| local FILES="$1" |
| local TYPE="$2" |
| local MESSAGE='' |
| |
| |
| |
| if [[ $# -lt 1 ]];then |
| cli_printMessage "${FUNCNAME}: `gettext "You need to provide one argument at least."`" 'AsErrorLine' |
| cli_printMessage "${FUNCDIRNAM}" "AsToKnowMoreLine" |
| fi |
| |
| for FILE in $FILES;do |
| |
| |
| |
| cli_checkPathComponent "$FILE" '--default' |
| |
| |
| case $TYPE in |
| |
| d | directory ) |
| |
| if [[ ! -d $FILE ]];then |
| MESSAGE="`eval_gettext "The directory \\\"\\\$FILE\\\" doesn't exist."`" |
| fi |
| ;; |
| |
| f | regular-file ) |
| # File exists and is a regular file. |
| if [[ ! -f $FILE ]];then |
| MESSAGE="`eval_gettext "The file \\\"\\\$FILE\\\" is not a regular file."`" |
| fi |
| ;; |
| |
| h | symbolic-link ) |
| # File exists and is a symbolic link. |
| if [[ ! -h $FILE ]];then |
| MESSAGE="`eval_gettext "The file \\\"\\\$FILE\\\" is not a symbolic link."`" |
| fi |
| ;; |
| |
| x | execution ) |
| # To exist, file should be executable. |
| if [[ ! -x $FILE ]];then |
| MESSAGE="`eval_gettext "The file \\\"\\\$FILE\\\" is not executable."`" |
| fi |
| ;; |
| |
| fh ) |
| # To exist, file should be a regular file or a symbolic link. |
| if [[ ! -f $FILE ]];then |
| if [[ ! -h $FILE ]];then |
| MESSAGE="`eval_gettext "The path \\\"\\\$FILE\\\" doesn't exist."`" |
| fi |
| fi |
| ;; |
| |
| fd ) |
| # To exist, file should be a regular file or a directory. |
| if [[ ! -f $FILE ]];then |
| if [[ ! -d $FILE ]];then |
| MESSAGE="`eval_gettext "The path \\\"\\\$FILE\\\" doesn't exist."`" |
| fi |
| fi |
| ;; |
| |
| isInWorkingCopy ) |
| # To exist, file should be inside the working copy. |
| if [[ ! $FILE =~ "^/home/centos/artwork/.+$" ]];then |
| MESSAGE="`eval_gettext "The path \\\"\\\$FILE\\\" doesn't exist inside the working copy."`" |
| fi |
| ;; |
| |
| * ) |
| # File exists. |
| if [[ ! -a $FILE ]];then |
| MESSAGE="`eval_gettext "The path \\\"\\\$FILE\\\" doesn't exist."`" |
| fi |
| |
| esac |
| |
| done |
| |
| # If file verification fails in anyway, output message information |
| # and end up script execution. Otherwise, continue with script |
| # normal flow. |
| if [[ "$MESSAGE" != '' ]];then |
| cli_printMessage "$MESSAGE" "AsErrorLine" |
| cli_printMessage "${FUNCDIRNAM}" "AsToKnowMoreLine" |
| fi |
| |
| } |
| |