Blame Scripts/Functions/cli_getTemporalFile.sh

93705a
#!/bin/bash
93705a
#
c92010
# cli_getTemporalFile.sh -- This function returns the absolute path
c92010
# you need to use to create temporal files. Use this function whenever
c92010
# you need to create temporal files inside centos-art.sh script.
93705a
#
9a3ef2
# Copyright (C) 2009-2011 Alain Reguera Delgado
fa95b1
#
fa95b1
# This program is free software; you can redistribute it and/or modify
fa95b1
# it under the terms of the GNU General Public License as published by
dcd347
# the Free Software Foundation; either version 2 of the License, or (at
dcd347
# your option) any later version.
fa95b1
#
74a058
# This program is distributed in the hope that it will be useful, but
74a058
# 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
dcd347
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
93705a
# ----------------------------------------------------------------------
93705a
# $Id$
93705a
# ----------------------------------------------------------------------
93705a
93705a
function cli_getTemporalFile {
93705a
c92010
    # Define base name for temporal file. This is required when svg
c92010
    # instances are created previous to be parsed by inkscape in order
c92010
    # to be exported as png. In such cases .svg file exention is
c92010
    # required in order to avoid complains from inkscape.
c92010
    local NAME="$(cli_getRepoName "$1" 'f')"
93705a
c92010
    # Check default base name for temporal file, it can't be an empty
c92010
    # value.
93705a
    if [[ "$NAME" == '' ]];then
c92010
        cli_printMessage "${FUNCNAME}: `gettext "First argument cannot be empty."`"
eee226
        cli_printMessage "${FUNCDIRNAM}" 'AsToKnowMoreLine'
93705a
    fi
93705a
c92010
    # Define source location where temporal files will be stored.
93705a
    local TMPDIR='/tmp'
93705a
93705a
    # Define unique identifier for temporal file.
93705a
    local UUID=$(cat /proc/sys/kernel/random/uuid)
93705a
c92010
    # Define absolute path for temporal file using the program name,
c92010
    # the current locale, the unique identifier and the file name. 
c92010
    local TMPFILE="${TMPDIR}/${CLI_PROGRAM}-$(cli_getCurrentLocale)-${UUID}-${NAME}"
93705a
93705a
    # Output absolute path to final temporal file.
93705a
    echo $TMPFILE
93705a
93705a
}