mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 04:22:34 +03:00
vfs: fix tempdir path building to account for trailing slash on macOS
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
This commit is contained in:
parent
e2d96fa802
commit
a3ce493ae2
@ -775,6 +775,7 @@ mc_tmpdir (void)
|
|||||||
static const char *tmpdir = NULL;
|
static const char *tmpdir = NULL;
|
||||||
const char *sys_tmp;
|
const char *sys_tmp;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
gchar *template;
|
||||||
|
|
||||||
/* Check if already correctly initialized */
|
/* Check if already correctly initialized */
|
||||||
if (tmpdir != NULL && lstat (tmpdir, &st) == 0 && S_ISDIR (st.st_mode) &&
|
if (tmpdir != NULL && lstat (tmpdir, &st) == 0 && S_ISDIR (st.st_mode) &&
|
||||||
@ -789,7 +790,10 @@ mc_tmpdir (void)
|
|||||||
sys_tmp = TMPDIR_DEFAULT;
|
sys_tmp = TMPDIR_DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_snprintf (buffer, sizeof (buffer), "%s/mc-XXXXXX", sys_tmp);
|
template = g_build_filename (sys_tmp, "mc-XXXXXX", (char *) NULL);
|
||||||
|
g_strlcpy (buffer, template, sizeof (buffer));
|
||||||
|
g_free (template);
|
||||||
|
|
||||||
tmpdir = g_mkdtemp (buffer);
|
tmpdir = g_mkdtemp (buffer);
|
||||||
if (tmpdir != NULL)
|
if (tmpdir != NULL)
|
||||||
g_setenv ("MC_TMPDIR", tmpdir, TRUE);
|
g_setenv ("MC_TMPDIR", tmpdir, TRUE);
|
||||||
|
@ -45,6 +45,9 @@
|
|||||||
static void
|
static void
|
||||||
setup (void)
|
setup (void)
|
||||||
{
|
{
|
||||||
|
/* Ensure that tests behave consistently irrespectively of the environment */
|
||||||
|
g_unsetenv ("MC_TMPDIR");
|
||||||
|
|
||||||
str_init_strings (NULL);
|
str_init_strings (NULL);
|
||||||
|
|
||||||
vfs_init ();
|
vfs_init ();
|
||||||
|
Loading…
Reference in New Issue
Block a user