1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-05 01:03:14 +02:00

Using new default value for DCC download dir (created at startup), fixed logs dir creation

This commit is contained in:
Sebastien Helleu
2006-03-04 15:37:20 +00:00
parent 919800c37c
commit 650805f204
24 changed files with 1240 additions and 1164 deletions
+14 -9
View File
@@ -107,15 +107,20 @@ void
log_start (t_gui_buffer *buffer)
{
int length;
char *ptr_home, *log_path, *log_path2, *ptr_path;
char *log_path, *log_path2;
ptr_home = getenv ("HOME");
log_path = weechat_strreplace (cfg_log_path, "~", ptr_home);
log_path2 = weechat_strreplace ((log_path) ?
log_path : cfg_log_path,
"%h", weechat_home);
ptr_path = (log_path2) ? log_path2 : ((log_path) ? log_path : cfg_log_path);
length = strlen (ptr_path) + 64;
log_path = weechat_strreplace (cfg_log_path, "~", getenv ("HOME"));
log_path2 = weechat_strreplace (log_path, "%h", weechat_home);
if (!log_path || !log_path2)
{
weechat_log_printf (_("Not enough memory to write log file for a buffer\n"));
if (log_path)
free (log_path);
if (log_path2)
free (log_path2);
return;
}
length = strlen (log_path2) + 64;
if (SERVER(buffer))
length += strlen (SERVER(buffer)->name);
if (CHANNEL(buffer))
@@ -132,7 +137,7 @@ log_start (t_gui_buffer *buffer)
return;
}
strcpy (buffer->log_filename, ptr_path);
strcpy (buffer->log_filename, log_path2);
if (log_path)
free (log_path);
if (log_path2)
+39 -14
View File
@@ -273,6 +273,9 @@ weechat_strreplace (char *string, char *search, char *replace)
char *pos, *new_string;
int length1, length2, length_new, count;
if (!string || !search || !replace)
return NULL;
length1 = strlen (search);
length2 = strlen (replace);
@@ -694,13 +697,13 @@ weechat_create_dir (char *directory)
}
/*
* weechat_create_home_dirs: create WeeChat directories (if not found)
* weechat_create_home_dirs: create WeeChat directories
*/
void
weechat_create_home_dirs ()
{
char *ptr_home, *dir_name;
char *ptr_home;
int dir_length;
if (!weechat_home)
@@ -732,21 +735,42 @@ weechat_create_home_dirs ()
WEECHAT_ERROR, weechat_home);
weechat_shutdown (EXIT_FAILURE, 0);
}
}
/*
* weechat_create_config_dirs: create config directories (read from config file)
*/
void
weechat_create_config_dirs ()
{
char *dir1, *dir2;
dir_length = strlen (weechat_home) + 64;
dir_name = (char *) malloc (dir_length * sizeof (char));
/* create "<weechat_home>/logs" */
snprintf (dir_name, dir_length, "%s%s%s", weechat_home, DIR_SEPARATOR,
"logs");
if (!weechat_create_dir (dir_name))
{
/* create logs directory" */
dir1 = weechat_strreplace (cfg_log_path, "~", getenv ("HOME"));
dir2 = weechat_strreplace (dir1, "%h", weechat_home);
if (weechat_create_dir (dir2))
chmod (dir2, 0700);
else
fprintf (stderr, _("%s unable to create \"%s\" directory\n"),
WEECHAT_WARNING, dir_name);
}
chmod (dir_name, 0700);
WEECHAT_WARNING, dir2);
if (dir1)
free (dir1);
if (dir2)
free (dir2);
free (dir_name);
/* create DCC download directory */
dir1 = weechat_strreplace (cfg_dcc_download_path, "~", getenv ("HOME"));
dir2 = weechat_strreplace (dir1, "%h", weechat_home);
if (weechat_create_dir (dir2))
chmod (dir2, 0700);
else
fprintf (stderr, _("%s unable to create \"%s\" directory\n"),
WEECHAT_WARNING, dir2);
if (dir1)
free (dir1);
if (dir2)
free (dir2);
}
/*
@@ -1040,6 +1064,7 @@ main (int argc, char *argv[])
weechat_init_log (); /* init log file */
command_index_build (); /* build cmd index for completion */
weechat_config_read (); /* read configuration */
weechat_create_config_dirs (); /* create config directories */
utf8_init (); /* init UTF-8 in WeeChat */
gui_init (); /* init WeeChat interface */
fifo_create (); /* FIFO pipe for remote control */
+1 -1
View File
@@ -791,7 +791,7 @@ t_config_option weechat_options_dcc[] =
{ "dcc_download_path", N_("path for incoming files with dcc"),
N_("path for writing incoming files with dcc (default: user home)"),
OPTION_TYPE_STRING, 0, 0, 0,
"~", NULL, NULL, &cfg_dcc_download_path, &config_change_noop },
"%h/dcc", NULL, NULL, &cfg_dcc_download_path, &config_change_noop },
{ "dcc_upload_path", N_("default path for sending files with dcc"),
N_("path for reading files when sending thru dcc (when no path is specified)"),
OPTION_TYPE_STRING, 0, 0, 0, "~",