#!/bin/bash
##############################################################################
# Copyright (c) Members of the EGEE Collaboration. 2004.
# See http://www.eu-egee.org/partners/ for details on the copyright
# holders.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS
# OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##############################################################################
#
# AUTHORS: Alejandro Álvarez Ayllón <alejandro.alvarez.ayllon@cern.ch>, CERN
#          Victor Galaktionov       <victor.galaktionov@cern.ch>
#
# Some common functions for all LFC tests
#
##############################################################################
# meta: ignore=true

# Removes a file from the LFC
# @param $1 The file
function lfc_clear {
  lfc-chmod 777 $1
  lfc-rm -r $1
}

# Checks the permissions of a file
# @param $1 User permissions (byte)
# @param $2 Group permissions (byte)
# @param $3 Other permissions (byte)
# @param $4 The file/directory
function lfc_checkMode {
    cdir=$4
    mode=$1$2$3
    QAC="d${access[$1]}${access[$2]}${access[$3]}"
    echo -n "   $QAC"    # " $mode"
                
    lfc-chmod $mode $cdir
                    
    lfc-ls -l $main_dir > $LFC_TEST_TMP
    grep $QAC $LFC_TEST_TMP > /dev/null
    if [ $? == 1 ]; then
        echo "Set mode: $mode" >&2
        echo "Get mode:" >&2
        cat $LFC_TEST_TMP >&2
        lfc-chmod 777 $cdir
        lfc_clear $main_dir
        test_exitFailure ""
    fi
}

# Removes a GUID
# @param $1 The GUID
function lfc_delGuid {
  echo "Delete $1"
  lcg-del -a $1
}

