Make tmp_dir if not found
This commit is contained in:
@@ -1138,6 +1138,9 @@ extern int symbol_width0;
|
|||||||
global int no_rc_dir init(FALSE);
|
global int no_rc_dir init(FALSE);
|
||||||
global char *rc_dir init(NULL);
|
global char *rc_dir init(NULL);
|
||||||
global char *tmp_dir;
|
global char *tmp_dir;
|
||||||
|
#ifdef HAVE_MKDTEMP
|
||||||
|
global char *mkd_tmp_dir init(NULL);
|
||||||
|
#endif
|
||||||
global char *config_file init(NULL);
|
global char *config_file init(NULL);
|
||||||
|
|
||||||
#ifdef USE_MOUSE
|
#ifdef USE_MOUSE
|
||||||
|
|||||||
@@ -6034,9 +6034,9 @@ w3m_exit(int i)
|
|||||||
WSACleanup();
|
WSACleanup();
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_MKDTEMP
|
#ifdef HAVE_MKDTEMP
|
||||||
if (no_rc_dir && tmp_dir != rc_dir)
|
if (mkd_tmp_dir)
|
||||||
if (rmdir(tmp_dir) != 0) {
|
if (rmdir(mkd_tmp_dir) != 0) {
|
||||||
fprintf(stderr, "Can't remove temporary directory (%s)!\n", tmp_dir);
|
fprintf(stderr, "Can't remove temporary directory (%s)!\n", mkd_tmp_dir);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -631,6 +631,7 @@ extern Str decodeMIME0(Str orgstr);
|
|||||||
extern int set_param_option(char *option);
|
extern int set_param_option(char *option);
|
||||||
extern char *get_param_option(char *name);
|
extern char *get_param_option(char *name);
|
||||||
extern void init_rc(void);
|
extern void init_rc(void);
|
||||||
|
extern void init_tmp(void);
|
||||||
extern Buffer *load_option_panel(void);
|
extern Buffer *load_option_panel(void);
|
||||||
extern void panel_set_option(struct parsed_tagarg *);
|
extern void panel_set_option(struct parsed_tagarg *);
|
||||||
extern void sync_with_option(void);
|
extern void sync_with_option(void);
|
||||||
|
|||||||
@@ -1291,6 +1291,7 @@ static void loadSiteconf(void);
|
|||||||
void
|
void
|
||||||
sync_with_option(void)
|
sync_with_option(void)
|
||||||
{
|
{
|
||||||
|
init_tmp();
|
||||||
if (PagerMax < LINES)
|
if (PagerMax < LINES)
|
||||||
PagerMax = LINES;
|
PagerMax = LINES;
|
||||||
WrapSearch = WrapDefault;
|
WrapSearch = WrapDefault;
|
||||||
@@ -1366,11 +1367,12 @@ init_rc(void)
|
|||||||
system_charset_str = display_charset_str;
|
system_charset_str = display_charset_str;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
tmp_dir = rc_dir;
|
||||||
|
|
||||||
if (do_recursive_mkdir(rc_dir) == -1)
|
if (do_recursive_mkdir(rc_dir) == -1)
|
||||||
goto rc_dir_err;
|
goto rc_dir_err;
|
||||||
|
|
||||||
no_rc_dir = FALSE;
|
no_rc_dir = FALSE;
|
||||||
tmp_dir = rc_dir;
|
|
||||||
|
|
||||||
if (config_file == NULL)
|
if (config_file == NULL)
|
||||||
config_file = rcFile(CONFIG_FILE);
|
config_file = rcFile(CONFIG_FILE);
|
||||||
@@ -1395,17 +1397,51 @@ init_rc(void)
|
|||||||
|
|
||||||
rc_dir_err:
|
rc_dir_err:
|
||||||
no_rc_dir = TRUE;
|
no_rc_dir = TRUE;
|
||||||
|
create_option_search_table();
|
||||||
|
goto open_rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
init_tmp(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (*tmp_dir == '\0')
|
||||||
|
tmp_dir = rc_dir;
|
||||||
|
|
||||||
|
if (strcmp(tmp_dir, rc_dir) == 0) {
|
||||||
|
if (no_rc_dir)
|
||||||
|
goto tmp_dir_err;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
tmp_dir = expandPath(tmp_dir);
|
||||||
|
i = strlen(tmp_dir);
|
||||||
|
if (i > 1 && tmp_dir[i - 1] == '/')
|
||||||
|
tmp_dir[i - 1] = '\0';
|
||||||
|
if (do_recursive_mkdir(tmp_dir) == -1)
|
||||||
|
goto tmp_dir_err;
|
||||||
|
return;
|
||||||
|
|
||||||
|
tmp_dir_err:
|
||||||
|
#ifdef HAVE_MKDTEMP
|
||||||
|
if (mkd_tmp_dir) {
|
||||||
|
tmp_dir = mkd_tmp_dir;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (((tmp_dir = getenv("TMPDIR")) == NULL || *tmp_dir == '\0') &&
|
if (((tmp_dir = getenv("TMPDIR")) == NULL || *tmp_dir == '\0') &&
|
||||||
((tmp_dir = getenv("TMP")) == NULL || *tmp_dir == '\0') &&
|
((tmp_dir = getenv("TMP")) == NULL || *tmp_dir == '\0') &&
|
||||||
((tmp_dir = getenv("TEMP")) == NULL || *tmp_dir == '\0'))
|
((tmp_dir = getenv("TEMP")) == NULL || *tmp_dir == '\0'))
|
||||||
tmp_dir = "/tmp";
|
tmp_dir = "/tmp";
|
||||||
#ifdef HAVE_MKDTEMP
|
#ifdef HAVE_MKDTEMP
|
||||||
tmp_dir = mkdtemp(Strnew_m_charp(tmp_dir, "/w3m-XXXXXX", NULL)->ptr);
|
tmp_dir = mkdtemp(Strnew_m_charp(tmp_dir, "/w3m-XXXXXX", NULL)->ptr);
|
||||||
if (tmp_dir == NULL)
|
if (tmp_dir)
|
||||||
|
mkd_tmp_dir = tmp_dir;
|
||||||
|
else
|
||||||
tmp_dir = rc_dir;
|
tmp_dir = rc_dir;
|
||||||
#endif
|
#endif
|
||||||
create_option_search_table();
|
return;
|
||||||
goto open_rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user