mirror of
https://github.com/transmission/transmission.git
synced 2025-12-24 12:28:52 +00:00
(gtk) #772, #753: added `watch dir' for automatically adding torrents. delete files to trashcan, rather than unlinking them. These features require 2.15.5 or higher.
This commit is contained in:
21
gtk/util.c
21
gtk/util.c
@@ -28,6 +28,10 @@
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <glib/gi18n.h>
|
||||
#include <glib/gstdio.h> /* g_unlink() */
|
||||
#ifdef HAVE_GIO
|
||||
#include <gio/gio.h> /* g_file_trash() */
|
||||
#endif
|
||||
|
||||
#include <libevent/evhttp.h>
|
||||
|
||||
@@ -416,3 +420,20 @@ tr_object_ref_sink( gpointer object )
|
||||
#endif
|
||||
return object;
|
||||
}
|
||||
|
||||
void
|
||||
tr_file_trash_or_unlink( const char * filename )
|
||||
{
|
||||
if( filename && *filename )
|
||||
{
|
||||
gboolean trashed = FALSE;
|
||||
#ifdef HAVE_GIO
|
||||
GError * err = NULL;
|
||||
GFile * file = g_file_new_for_path( filename );
|
||||
trashed = g_file_trash( file, NULL, &err );
|
||||
g_object_unref( G_OBJECT( file ) );
|
||||
#endif
|
||||
if( !trashed )
|
||||
g_unlink( filename );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user