mirror of
https://github.com/moparisthebest/hexchat
synced 2025-02-21 13:11:52 -05:00
Use Gio for load_perform_file()
This commit is contained in:
parent
63a6f4a81f
commit
6617d92512
@ -2533,30 +2533,32 @@ cmd_list (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
load_perform_file (session *sess, char *file)
|
load_perform_file (session *sess, char *filename)
|
||||||
{
|
{
|
||||||
char tbuf[1024 + 4];
|
GFile *file;
|
||||||
char *nl;
|
GDataInputStream *istream;
|
||||||
FILE *fp;
|
gchar *buf;
|
||||||
|
|
||||||
fp = hexchat_fopen_file (file, "r", 0); /* load files from config dir */
|
file = hexchat_open_gfile (filename);
|
||||||
if (!fp)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
tbuf[1024] = 0;
|
istream = file_get_datainputstream (file);
|
||||||
while (fgets (tbuf, 1024, fp))
|
if (!istream)
|
||||||
{
|
{
|
||||||
nl = strchr (tbuf, '\n');
|
g_object_unref (file);
|
||||||
if (nl == tbuf) /* skip empty commands */
|
return FALSE;
|
||||||
continue;
|
|
||||||
if (nl)
|
|
||||||
*nl = 0;
|
|
||||||
if (tbuf[0] == prefs.hex_input_command_char[0])
|
|
||||||
handle_command (sess, tbuf + 1, TRUE);
|
|
||||||
else
|
|
||||||
handle_command (sess, tbuf, TRUE);
|
|
||||||
}
|
}
|
||||||
fclose (fp);
|
|
||||||
|
while ((buf = g_data_input_stream_read_line_utf8 (istream, NULL, NULL, NULL)))
|
||||||
|
{
|
||||||
|
if (g_str_has_prefix (buf, prefs.hex_input_command_char))
|
||||||
|
handle_command (sess, buf + 1, TRUE);
|
||||||
|
else
|
||||||
|
handle_command (sess, buf, TRUE);
|
||||||
|
g_free (buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_object_unref (file);
|
||||||
|
g_object_unref (istream);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user