#include "gioalias.h"
-static void g_local_file_file_iface_init (GFileIface *iface);
+static void g_local_file_file_iface_init (GFileIface *iface);
static GFileAttributeInfoList *local_writable_attributes = NULL;
static GFileAttributeInfoList *local_writable_namespaces = NULL;
G_IMPLEMENT_INTERFACE (G_TYPE_FILE,
g_local_file_file_iface_init))
-static char * find_mountpoint_for (const char *file, dev_t dev);
+static char *find_mountpoint_for (const char *file, dev_t dev);
static void
g_local_file_finalize (GObject *object)
while ((c = *string++) != 0)
{
- if (g_ascii_iscntrl(c))
+ if (g_ascii_iscntrl (c))
return FALSE;
}
prefix_len = strlen (prefix);
if (strncmp (path, prefix, prefix_len) != 0)
return NULL;
+
+ /* Handle the case where prefix is the root, so that
+ * the IS_DIR_SEPRARATOR check below works */
+ if (prefix_len > 0 &&
+ G_IS_DIR_SEPARATOR (prefix[prefix_len-1]))
+ prefix_len--;
+
return path + prefix_len;
}
device_equal (gconstpointer v1,
gconstpointer v2)
{
- return *(dev_t *)v1 == * (dev_t *)v2;
+ return *(dev_t *)v1 == *(dev_t *)v2;
}
static guint
return NULL;
}
- new_file = g_file_get_child_for_display_name (parent, display_name, error);
+ new_file = g_file_get_child_for_display_name (parent, display_name, error);
g_object_unref (parent);
if (new_file == NULL)
}
static gboolean
-g_local_file_set_attribute (GFile *file,
- const char *attribute,
- GFileAttributeType type,
- gpointer value_p,
- GFileQueryInfoFlags flags,
- GCancellable *cancellable,
- GError **error)
+g_local_file_set_attribute (GFile *file,
+ const char *attribute,
+ GFileAttributeType type,
+ gpointer value_p,
+ GFileQueryInfoFlags flags,
+ GCancellable *cancellable,
+ GError **error)
{
GLocalFile *local = G_LOCAL_FILE (file);
{
GLocalFile *local = G_LOCAL_FILE (file);
int res, chained_res;
- GFileIface* default_iface;
+ GFileIface *default_iface;
res = _g_local_file_info_set_attributes (local->filename,
info, flags,
dot = strchr (basename, '.');
if (dot)
- return g_strdup_printf ("%.*s.%d%s", dot - basename, basename, id, dot);
+ return g_strdup_printf ("%.*s.%d%s", (int)(dot - basename), basename, id, dot);
else
return g_strdup_printf ("%s.%d", basename, id);
}
gpointer progress_callback_data,
GError **error)
{
- GLocalFile *local_source = G_LOCAL_FILE (source);
+ GLocalFile *local_source;
GLocalFile *local_destination = G_LOCAL_FILE (destination);
struct stat statbuf;
gboolean destination_exist, source_is_dir;
char *backup_name;
int res;
-
+ off_t source_size;
+
+ if (!G_IS_LOCAL_FILE (source) ||
+ !G_IS_LOCAL_FILE (destination))
+ {
+ /* Fall back to default move */
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, "Move not supported");
+ return FALSE;
+ }
+
+ local_source = G_LOCAL_FILE (source);
+
res = g_lstat (local_source->filename, &statbuf);
if (res == -1)
{
}
else
source_is_dir = S_ISDIR (statbuf.st_mode);
+
+ source_size = statbuf.st_size;
destination_exist = FALSE;
res = g_lstat (local_destination->filename, &statbuf);
_("Error moving file: %s"),
g_strerror (errsv));
return FALSE;
-
}
+
+ /* Make sure we send full copied size */
+ if (progress_callback)
+ progress_callback (source_size, source_size, progress_callback_data);
+
return TRUE;
}
-static GDirectoryMonitor*
+static GFileMonitor*
g_local_file_monitor_dir (GFile *file,
GFileMonitorFlags flags,
- GCancellable *cancellable)
+ GCancellable *cancellable,
+ GError **error)
{
GLocalFile* local_file = G_LOCAL_FILE(file);
- return _g_local_directory_monitor_new (local_file->filename, flags);
+ return _g_local_directory_monitor_new (local_file->filename, flags, error);
}
static GFileMonitor*
g_local_file_monitor_file (GFile *file,
GFileMonitorFlags flags,
- GCancellable *cancellable)
+ GCancellable *cancellable,
+ GError **error)
{
GLocalFile* local_file = G_LOCAL_FILE(file);
- return _g_local_file_monitor_new (local_file->filename, flags);
+ return _g_local_file_monitor_new (local_file->filename, flags, error);
}
static void