* utilunix.c (mc_tmpdir): New function that returns temporary
directory for mc. * util.c (mc_mkstemps): Use mc_tmpdir(). * main.c (main): Call mc_tmpdir().
Этот коммит содержится в:
родитель
83d0b9a9d6
Коммит
485b40ac2a
@ -1,3 +1,10 @@
|
||||
2002-09-11 Pavel Roskin <proski@gnu.org>
|
||||
|
||||
* utilunix.c (mc_tmpdir): New function that returns temporary
|
||||
directory for mc.
|
||||
* util.c (mc_mkstemps): Use mc_tmpdir().
|
||||
* main.c (main): Call mc_tmpdir().
|
||||
|
||||
2002-09-10 Pavel Roskin <proski@gnu.org>
|
||||
|
||||
* util.c (trim): Handle short strings even better - don't use
|
||||
|
@ -2449,7 +2449,10 @@ main (int argc, char *argv [])
|
||||
|
||||
/* Initialize list of all user group for timur_clr_mode */
|
||||
init_groups ();
|
||||
|
||||
|
||||
/* Set up temporary directory */
|
||||
mc_tmpdir ();
|
||||
|
||||
OS_Setup ();
|
||||
|
||||
/* This variable is used by the subshell */
|
||||
|
@ -1205,15 +1205,8 @@ int mc_mkstemps(char **pname, const char *prefix, const char *suffix)
|
||||
int count;
|
||||
|
||||
if (strchr(prefix, PATH_SEP) == NULL) {
|
||||
char *tmpdir;
|
||||
|
||||
tmpdir = getenv("TMPDIR");
|
||||
if (!tmpdir) {
|
||||
tmpdir = TMPDIR_DEFAULT;
|
||||
}
|
||||
|
||||
/* Add prefix first to find the position of XXXXXX */
|
||||
tmpbase = concat_dir_and_file (tmpdir, prefix);
|
||||
tmpbase = concat_dir_and_file (mc_tmpdir (), prefix);
|
||||
} else {
|
||||
tmpbase = g_strdup (prefix);
|
||||
}
|
||||
|
@ -88,6 +88,7 @@ char *canonicalize_pathname (char *);
|
||||
|
||||
/* Misc Unix functions */
|
||||
char *get_current_wd (char *buffer, int size);
|
||||
const char *mc_tmpdir (void);
|
||||
int my_mkdir (char *s, mode_t mode);
|
||||
int my_rmdir (char *s);
|
||||
|
||||
|
@ -298,6 +298,44 @@ char *tilde_expand (const char *directory)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Return the directory where mc should keep its temporary files.
|
||||
* This directory is (in Bourne shell terms) "${TMPDIR=/tmp}-$USER"
|
||||
* When called the first time, the directory is created if needed.
|
||||
* The first call should be done early, since we are using fprintf()
|
||||
* and not message() to report possible problems.
|
||||
*/
|
||||
const char *
|
||||
mc_tmpdir (void)
|
||||
{
|
||||
static char tmpdir[64];
|
||||
const char *sys_tmp;
|
||||
struct passwd *pwd;
|
||||
|
||||
if (*tmpdir)
|
||||
return tmpdir;
|
||||
|
||||
sys_tmp = getenv ("TMPDIR");
|
||||
if (!sys_tmp) {
|
||||
sys_tmp = TMPDIR_DEFAULT;
|
||||
}
|
||||
|
||||
pwd = getpwuid (getuid ());
|
||||
g_snprintf (tmpdir, sizeof (tmpdir), "%s/mc-%s", sys_tmp,
|
||||
pwd->pw_name);
|
||||
canonicalize_pathname (tmpdir);
|
||||
|
||||
/* No recursion or VFS here. If $TMPDIR is missing, exit. */
|
||||
if (mkdir (tmpdir, 0700) != 0 && errno != EEXIST) {
|
||||
fprintf (stderr, _("Cannot create temporary directory %s: %s\n"),
|
||||
tmpdir, unix_error_string (errno));
|
||||
exit (1);
|
||||
}
|
||||
|
||||
return tmpdir;
|
||||
}
|
||||
|
||||
|
||||
/* Pipes are guaranteed to be able to hold at least 4096 bytes */
|
||||
/* More than that would be unportable */
|
||||
#define MAX_PIPE_SIZE 4096
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user