Example #1
0
char *
get_xdir_utf8 (void)
{
	if (!xdir_utf)	/* never free this, keep it for program life time */
		xdir_utf = xchat_filename_to_utf8 (get_xdir_fs (), -1, 0, 0, 0);

	return xdir_utf;
}
Example #2
0
static void
gtkutil_check_file (char *file, struct file_req *freq)
{
	struct stat st;
	int axs = FALSE;

	path_part (file, last_dir, sizeof (last_dir));

	/* check if the file is readable or writable */
	if (freq->flags & FRF_WRITE)
	{
		if (access (last_dir, W_OK) == 0)
			axs = TRUE;
	} else
	{
		if (stat (file, &st) != -1)
		{
			if (!S_ISDIR (st.st_mode) || (freq->flags & FRF_CHOOSEFOLDER))
				axs = TRUE;
		}
	}

	if (axs)
	{
		char *utf8_file;
		/* convert to UTF8. It might be converted back to locale by
			server.c's g_convert */
		utf8_file = xchat_filename_to_utf8 (file, -1, NULL, NULL, NULL);
		if (utf8_file)
		{
			freq->callback (freq->userdata, utf8_file);
			g_free (utf8_file);
		} else
		{
			fe_message ("Filename encoding is corrupt.", FE_MSG_ERROR);
		}
	} else
	{
		if (freq->flags & FRF_WRITE)
			fe_message (_("Cannot write to that file."), FE_MSG_ERROR);
		else
			fe_message (_("Cannot read that file."), FE_MSG_ERROR);
	}
}