Skip to content
Snippets Groups Projects
Commit 3ecc5abc authored by Sergey Ponomarev's avatar Sergey Ponomarev Committed by Alexander Schwinn
Browse files

sendto plugin: extract function tse_file_is_archive

(Bug #15916)

Signed-off-by: default avatarSergey Ponomarev <stokito@gmail.com>
Signed-off-by: Alexander Schwinn's avatarAlexander Schwinn <alexxcons@xfce.org>
parent 0c74c717
No related branches found
No related tags found
No related merge requests found
......@@ -139,12 +139,36 @@ tse_error (GError *error,
g_free (primary_text);
}
/**
* Check if the single file is already an archive
**/
static gboolean
tse_file_is_archive (GFileInfo *file_info)
{
const gchar *content_type;
guint n;
/* determine the content type */
content_type = g_file_info_get_content_type (file_info);
if (content_type == NULL)
{
return FALSE;
}
for (n = 0; n < G_N_ELEMENTS (TSE_MIME_TYPES); ++n)
{
/* check if this mime type matches */
if (g_content_type_is_a (content_type, TSE_MIME_TYPES[n]))
{
/* yep, that's a match then */
return TRUE;
}
}
return FALSE;
}
static gint
tse_ask_compress (GList *infos)
{
const gchar *content_type;
TseData *tse_data;
GtkWidget *message;
guint64 total_size = 0;
......@@ -152,7 +176,6 @@ tse_ask_compress (GList *infos)
gint response = TSE_RESPONSE_PLAIN;
gint n_archives = 0;
gint n_infos = 0;
guint n;
/* check the file infos */
for (lp = infos; lp != NULL; lp = lp->next, ++n_infos)
......@@ -163,19 +186,8 @@ tse_ask_compress (GList *infos)
if (g_file_info_get_file_type (tse_data->info) == G_FILE_TYPE_DIRECTORY)
return TSE_RESPONSE_COMPRESS;
/* determine the content type */
content_type = g_file_info_get_content_type (tse_data->info);
/* check if the single file is already an archive */
for (n = 0; n < G_N_ELEMENTS (TSE_MIME_TYPES); ++n)
{
/* check if this mime type matches */
if (content_type != NULL && g_content_type_is_a (content_type, TSE_MIME_TYPES[n]))
{
/* yep, that's a match then */
++n_archives;
break;
}
}
if (tse_file_is_archive (tse_data->info))
++n_archives;
/* add file size to total */
total_size += g_file_info_get_size (tse_data->info);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment