Blame Scripts/Bash/Functions/cli_getTemporalFile.sh

878a2b
#!/bin/bash
878a2b
#
878a2b
# cli_getTemporalFile.sh -- This function returns the absolute path
878a2b
# you need to use to create temporal files. Use this function whenever
878a2b
# you need to create temporal files inside centos-art.sh script.
878a2b
#
878a2b
# Copyright (C) 2009, 2010, 2011 The CentOS Project
878a2b
#
878a2b
# This program is free software; you can redistribute it and/or modify
878a2b
# it under the terms of the GNU General Public License as published by
878a2b
# the Free Software Foundation; either version 2 of the License, or (at
878a2b
# your option) any later version.
878a2b
#
878a2b
# This program is distributed in the hope that it will be useful, but
878a2b
# WITHOUT ANY WARRANTY; without even the implied warranty of
878a2b
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
878a2b
# General Public License for more details.
878a2b
#
878a2b
# You should have received a copy of the GNU General Public License
878a2b
# along with this program; if not, write to the Free Software
878a2b
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
878a2b
#
878a2b
# ----------------------------------------------------------------------
878a2b
# $Id$
878a2b
# ----------------------------------------------------------------------
878a2b
878a2b
function cli_getTemporalFile {
878a2b
878a2b
    # Define base name for temporal file. This is required when svg
878a2b
    # instances are created previous to be parsed by inkscape in order
878a2b
    # to be exported as png. In such cases .svg file exention is
878a2b
    # required in order to avoid complains from inkscape.
878a2b
    local NAME="$(cli_getRepoName $1 -f)"
878a2b
878a2b
    # Check default base name for temporal file, it can't be an empty
878a2b
    # value.
878a2b
    if [[ "$NAME" == '' ]];then
878a2b
        cli_printMessage "`gettext "The first argument cannot be empty."`" --as-error-line
878a2b
    fi
878a2b
878a2b
    # Redefine file name for the temporal file. Make it a combination
878a2b
    # of the program name, the program process id, a random string and
878a2b
    # the design model name. Using the program name and process id in
878a2b
    # the file name let us to relate both the shell script execution
878a2b
    # and the temporal files it creates, so they can be removed in
878a2b
    # case an interruption signal be detected. The random string let
878a2b
    # us to produce the same artwork in different terminals at the
878a2b
    # same time. the The design model name provides file
878a2b
    # identification.
383e21
    NAME=${CLI_NAME}-${CLI_PPID}-${RANDOM}-${NAME}
878a2b
878a2b
    # Define absolute path for temporal file using the program name,
878a2b
    # the current locale, the unique identifier and the file name. 
878a2b
    local TEMPFILE="${CLI_TEMPDIR}/${NAME}"
878a2b
878a2b
    # Output absolute path to final temporal file.
878a2b
    echo $TEMPFILE
878a2b
878a2b
}