Blame Scripts/Bash/centos-art/Functions/cli_getTemporalFile.sh

93705a
#!/bin/bash
93705a
#
93705a
# cli_getTemporalFile.sh -- This function returns absolute path to
93705a
# temporal file. Use this function whenever you need to create
93705a
# temporal files inside centos-art.sh script.
93705a
#
9a3ef2
# Copyright (C) 2009-2011 Alain Reguera Delgado
93705a
# 
7cd8e9
# This program is free software; you can redistribute it and/or
7cd8e9
# modify it under the terms of the GNU General Public License as
7cd8e9
# published by the Free Software Foundation; either version 2 of the
7cd8e9
# License, or (at your option) any later version.
93705a
# 
93705a
# This program is distributed in the hope that it will be useful, but
93705a
# WITHOUT ANY WARRANTY; without even the implied warranty of
93705a
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
93705a
# General Public License for more details.
93705a
#
93705a
# You should have received a copy of the GNU General Public License
93705a
# along with this program; if not, write to the Free Software
93705a
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
93705a
# USA.
93705a
# 
93705a
# ----------------------------------------------------------------------
93705a
# $Id$
93705a
# ----------------------------------------------------------------------
93705a
93705a
function cli_getTemporalFile {
93705a
93705a
    # Check amount arguments passed to this function.
93705a
    if [[ $# -ne 1 ]];then
93705a
        cli_printMessage "cli_getTemporalFile: `gettext "First argument is required."`"
93705a
        cli_printMessage "$(caller)" 'ToKnowMoreLine'
93705a
    fi
93705a
93705a
    # Define default basename for temporal file. This is required when
93705a
    # svg instances are created previous to be parsed by inkscape in
93705a
    # order to be exported as png. In such cases .svg file exention is
93705a
    # required in order to avoid inkscape complains.
93705a
    local NAME="$1"
93705a
    if [[ "$NAME" == '' ]];then
93705a
        cli_printMessage "cli_getTemporalFile: `gettext "First argument cannot be empty."`"
93705a
        cli_printMessage "$(caller)" 'AsToKnowMoreLine'
93705a
    else
235dfc
        NAME="-$(cli_getCurrentLocale)-$(cli_getRepoName "$1" 'f')" 
93705a
    fi
93705a
93705a
    # Define default source location where temporal files will be stored.
93705a
    local TMPDIR='/tmp'
93705a
93705a
    # Define default prefix for temporal file.
93705a
    local PREFIX='centos-art.sh-'
93705a
93705a
    # Define unique identifier for temporal file.
93705a
    local UUID=$(cat /proc/sys/kernel/random/uuid)
93705a
93705a
    # Join default source location and filename to build final
93705a
    # temporal file absolute path.
93705a
    local TMPFILE=$(echo -n "${TMPDIR}/${PREFIX}${UUID}${NAME}")
93705a
93705a
    # Output absolute path to final temporal file.
93705a
    echo $TMPFILE
93705a
93705a
}