(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:
Charles Kerr
2008-03-09 15:27:08 +00:00
parent e85a328b1b
commit e4562bcd7b
11 changed files with 180 additions and 21 deletions

View File

@@ -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 );
}
}