1 /** \file archdep_make_backup_filename.c
2 * \brief Generate a backup filename for a file
3 * \author Bas Wassink <b.wassink@ziggo.nl>
4 */
5
6 /*
7 * This file is part of VICE, the Versatile Commodore Emulator.
8 * See README for copyright notice.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23 * 02111-1307 USA.
24 *
25 */
26
27 #include "vice.h"
28 #include "archdep_defs.h"
29
30 #include "lib.h"
31 #include "util.h"
32
33 #include "archdep_make_backup_filename.h"
34
35 /* BEOS */
36 #if 0
37 /* Return a malloc'ed backup file name for file `fname'. */
archdep_make_backup_filename(const char * fname)38 char *archdep_make_backup_filename(const char *fname)
39 {
40 char *tmp;
41
42 tmp = util_concat(fname, NULL);
43 tmp[strlen(tmp) - 1] = '~';
44 return tmp;
45 }
46 #endif
47
48 /** \brief Generate backup filename for \a fname
49 *
50 * \param[in] fname original filename
51 *
52 * \return backup filename (free with libfree())
53 */
archdep_make_backup_filename(const char * fname)54 char *archdep_make_backup_filename(const char *fname)
55 {
56 #ifdef ARCHDEP_OS_WIN32
57 /* For some reason on Windows, we replace the last char with a tilde, which
58 * ofcourse is stupid idea since the last char could be a tilde.
59 */
60 char *bak = lib_strdup(fname);
61 bak[strlen(bak) = 1] = '~';
62 return bak
63 #else
64 return util_concat(fname, "~", NULL);
65 #endif
66 }
67