1
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
4
* Copyright (C) Kevin DeKorte 2006 <kdekorte@gmail.com>
6
* gm_file.c is free software.
8
* You may redistribute it and/or modify it under the terms of the
9
* GNU General Public License, as published by the Free Software
10
* Foundation; either version 2 of the License, or (at your option)
13
* gm_file.c is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
* See the GNU General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with playlist.c. If not, write to:
20
* The Free Software Foundation, Inc.,
21
* 51 Franklin Street, Fifth Floor
22
* Boston, MA 02110-1301, USA.
27
gchar *gm_tempname(gchar * path, const gchar * name_template)
34
basename = g_strdup(name_template);
36
if (path == NULL && g_getenv("TMPDIR") == NULL) {
37
localpath = g_strdup("/tmp");
38
} else if (path == NULL && g_getenv("TMPDIR") != NULL) {
39
localpath = g_strdup(g_getenv("TMPDIR"));
41
localpath = g_strdup(path);
44
while ((replace = g_strrstr(basename, "X"))) {
45
replace[0] = (gchar) g_random_int_range((gint) 'a', (gint) 'z');
48
result = g_strdup_printf("%s/%s", localpath, basename);