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
#
2d3646
# Copyright (C) 2009, 2010, 2011 The CentOS Project
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.
7ac5a5
#
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.
39ae1a
    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
37af2a
        cli_printMessage "`gettext "The first argument cannot be empty."`" --as-error-line
93705a
    fi
93705a
c92010
    # Define source location where temporal files will be stored.
93705a
    local TMPDIR='/tmp'
93705a
c92010
    # Define absolute path for temporal file using the program name,
c92010
    # the current locale, the unique identifier and the file name. 
37af2a
    local TMPFILE="${TMPDIR}/${CLI_PROGRAM}-${RANDOM}-${NAME}"
93705a
93705a
    # Output absolute path to final temporal file.
93705a
    echo $TMPFILE
93705a
93705a
}