1 /* GIO - GLib Input, Output and Streaming Library
3 * Copyright (C) 2006-2007 Red Hat, Inc.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General
16 * Public License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18 * Boston, MA 02111-1307, USA.
20 * Author: Alexander Larsson <alexl@redhat.com>
25 #include <sys/types.h>
35 #include <sys/statfs.h>
37 #if HAVE_SYS_STATVFS_H
38 #include <sys/statvfs.h>
42 #elif HAVE_SYS_MOUNT_H
44 #include <sys/param.h>
46 #include <sys/mount.h>
53 #if defined(HAVE_STATFS) && defined(HAVE_STATVFS)
54 /* Some systems have both statfs and statvfs, pick the
55 most "native" for these */
56 # if !defined(HAVE_STRUCT_STATFS_F_BAVAIL)
57 /* on solaris and irix, statfs doesn't even have the
61 /* at least on linux, statfs is the actual syscall */
65 #elif defined(HAVE_STATFS)
69 #elif defined(HAVE_STATVFS)
75 #include "gfileattribute.h"
76 #include "glocalfile.h"
77 #include "glocalfileinfo.h"
78 #include "glocalfileenumerator.h"
79 #include "glocalfileinputstream.h"
80 #include "glocalfileoutputstream.h"
81 #include "glocaldirectorymonitor.h"
82 #include "glocalfilemonitor.h"
83 #include "gmountprivate.h"
84 #include "gunixmounts.h"
86 #include <glib/gstdio.h>
90 #define _WIN32_WINNT 0x0500
95 #ifndef FILE_READ_ONLY_VOLUME
96 #define FILE_READ_ONLY_VOLUME 0x00080000
100 #define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
103 #define S_ISLNK(m) (0)
107 #include "gioalias.h"
109 static void g_local_file_file_iface_init (GFileIface *iface);
111 static GFileAttributeInfoList *local_writable_attributes = NULL;
112 static GFileAttributeInfoList *local_writable_namespaces = NULL;
116 GObject parent_instance;
121 #define g_local_file_get_type _g_local_file_get_type
122 G_DEFINE_TYPE_WITH_CODE (GLocalFile, g_local_file, G_TYPE_OBJECT,
123 G_IMPLEMENT_INTERFACE (G_TYPE_FILE,
124 g_local_file_file_iface_init))
126 static char *find_mountpoint_for (const char *file, dev_t dev);
129 g_local_file_finalize (GObject *object)
133 local = G_LOCAL_FILE (object);
135 g_free (local->filename);
137 G_OBJECT_CLASS (g_local_file_parent_class)->finalize (object);
141 g_local_file_class_init (GLocalFileClass *klass)
143 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
144 GFileAttributeInfoList *list;
146 gobject_class->finalize = g_local_file_finalize;
148 /* Set up attribute lists */
150 /* Writable attributes: */
152 list = g_file_attribute_info_list_new ();
154 g_file_attribute_info_list_add (list,
155 G_FILE_ATTRIBUTE_UNIX_MODE,
156 G_FILE_ATTRIBUTE_TYPE_UINT32,
157 G_FILE_ATTRIBUTE_INFO_COPY_WITH_FILE |
158 G_FILE_ATTRIBUTE_INFO_COPY_WHEN_MOVED);
161 g_file_attribute_info_list_add (list,
162 G_FILE_ATTRIBUTE_UNIX_UID,
163 G_FILE_ATTRIBUTE_TYPE_UINT32,
164 G_FILE_ATTRIBUTE_INFO_COPY_WHEN_MOVED);
165 g_file_attribute_info_list_add (list,
166 G_FILE_ATTRIBUTE_UNIX_GID,
167 G_FILE_ATTRIBUTE_TYPE_UINT32,
168 G_FILE_ATTRIBUTE_INFO_COPY_WHEN_MOVED);
172 g_file_attribute_info_list_add (list,
173 G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET,
174 G_FILE_ATTRIBUTE_TYPE_BYTE_STRING,
179 g_file_attribute_info_list_add (list,
180 G_FILE_ATTRIBUTE_TIME_MODIFIED,
181 G_FILE_ATTRIBUTE_TYPE_UINT64,
182 G_FILE_ATTRIBUTE_INFO_COPY_WITH_FILE |
183 G_FILE_ATTRIBUTE_INFO_COPY_WHEN_MOVED);
184 g_file_attribute_info_list_add (list,
185 G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC,
186 G_FILE_ATTRIBUTE_TYPE_UINT32,
187 G_FILE_ATTRIBUTE_INFO_COPY_WITH_FILE |
188 G_FILE_ATTRIBUTE_INFO_COPY_WHEN_MOVED);
189 /* When copying, the target file is accessed. Replicating
190 * the source access time does not make sense in this case.
192 g_file_attribute_info_list_add (list,
193 G_FILE_ATTRIBUTE_TIME_ACCESS,
194 G_FILE_ATTRIBUTE_TYPE_UINT64,
195 G_FILE_ATTRIBUTE_INFO_COPY_WHEN_MOVED);
196 g_file_attribute_info_list_add (list,
197 G_FILE_ATTRIBUTE_TIME_ACCESS_USEC,
198 G_FILE_ATTRIBUTE_TYPE_UINT32,
199 G_FILE_ATTRIBUTE_INFO_COPY_WHEN_MOVED);
202 local_writable_attributes = list;
204 /* Writable namespaces: */
206 list = g_file_attribute_info_list_new ();
209 g_file_attribute_info_list_add (list,
211 G_FILE_ATTRIBUTE_TYPE_STRING,
212 G_FILE_ATTRIBUTE_INFO_COPY_WITH_FILE |
213 G_FILE_ATTRIBUTE_INFO_COPY_WHEN_MOVED);
214 g_file_attribute_info_list_add (list,
216 G_FILE_ATTRIBUTE_TYPE_STRING,
217 G_FILE_ATTRIBUTE_INFO_COPY_WHEN_MOVED);
220 local_writable_namespaces = list;
224 g_local_file_init (GLocalFile *local)
230 canonicalize_filename (const char *filename)
232 char *canon, *start, *p, *q;
236 if (!g_path_is_absolute (filename))
238 cwd = g_get_current_dir ();
239 canon = g_build_filename (cwd, filename, NULL);
243 canon = g_strdup (filename);
245 start = (char *)g_path_skip_root (canon);
247 /* POSIX allows double slashes at the start to
248 * mean something special (as does windows too).
249 * So, "//" != "/", but more than two slashes
255 G_IS_DIR_SEPARATOR (*p);
262 memmove (start, start+i, strlen (start+i)+1);
268 if (p[0] == '.' && (p[1] == 0 || G_IS_DIR_SEPARATOR (p[1])))
270 memmove (p, p+1, strlen (p+1)+1);
272 else if (p[0] == '.' && p[1] == '.' && (p[2] == 0 || G_IS_DIR_SEPARATOR (p[2])))
275 /* Skip previous separator */
279 while (p > start && !G_IS_DIR_SEPARATOR (*p))
281 if (G_IS_DIR_SEPARATOR (*p))
282 *p++ = G_DIR_SEPARATOR;
283 memmove (p, q, strlen (q)+1);
287 /* Skip until next separator */
288 while (*p != 0 && !G_IS_DIR_SEPARATOR (*p))
293 /* Canonicalize one separator */
294 *p++ = G_DIR_SEPARATOR;
298 /* Remove additional separators */
300 while (*q && G_IS_DIR_SEPARATOR (*q))
304 memmove (p, q, strlen (q)+1);
307 /* Remove trailing slashes */
308 if (p > start && G_IS_DIR_SEPARATOR (*(p-1)))
316 * @filename: filename of the file to create.
318 * Returns: new local #GFile.
321 _g_local_file_new (const char *filename)
325 local = g_object_new (G_TYPE_LOCAL_FILE, NULL);
326 local->filename = canonicalize_filename (filename);
328 return G_FILE (local);
332 g_local_file_is_native (GFile *file)
338 g_local_file_has_uri_scheme (GFile *file,
339 const char *uri_scheme)
341 return g_ascii_strcasecmp (uri_scheme, "file") == 0;
345 g_local_file_get_uri_scheme (GFile *file)
347 return g_strdup ("file");
351 g_local_file_get_basename (GFile *file)
353 return g_path_get_basename (G_LOCAL_FILE (file)->filename);
357 g_local_file_get_path (GFile *file)
359 return g_strdup (G_LOCAL_FILE (file)->filename);
363 g_local_file_get_uri (GFile *file)
365 return g_filename_to_uri (G_LOCAL_FILE (file)->filename, NULL, NULL);
369 get_filename_charset (const gchar **filename_charset)
371 const gchar **charsets;
374 is_utf8 = g_get_filename_charsets (&charsets);
376 if (filename_charset)
377 *filename_charset = charsets[0];
383 name_is_valid_for_display (const char *string,
384 gboolean is_valid_utf8)
388 if (!is_valid_utf8 &&
389 !g_utf8_validate (string, -1, NULL))
392 while ((c = *string++) != 0)
394 if (g_ascii_iscntrl (c))
402 g_local_file_get_parse_name (GFile *file)
404 const char *filename;
406 const gchar *charset;
408 char *roundtripped_filename;
409 gboolean free_utf8_filename;
410 gboolean is_valid_utf8;
413 filename = G_LOCAL_FILE (file)->filename;
414 if (get_filename_charset (&charset))
416 utf8_filename = (char *)filename;
417 free_utf8_filename = FALSE;
418 is_valid_utf8 = FALSE; /* Can't guarantee this */
422 utf8_filename = g_convert (filename, -1,
423 "UTF-8", charset, NULL, NULL, NULL);
424 free_utf8_filename = TRUE;
425 is_valid_utf8 = TRUE;
427 if (utf8_filename != NULL)
429 /* Make sure we can roundtrip: */
430 roundtripped_filename = g_convert (utf8_filename, -1,
431 charset, "UTF-8", NULL, NULL, NULL);
433 if (roundtripped_filename == NULL ||
434 strcmp (utf8_filename, roundtripped_filename) != 0)
436 g_free (utf8_filename);
437 utf8_filename = NULL;
440 g_free (roundtripped_filename);
444 if (utf8_filename != NULL &&
445 name_is_valid_for_display (utf8_filename, is_valid_utf8))
447 if (free_utf8_filename)
448 parse_name = utf8_filename;
450 parse_name = g_strdup (utf8_filename);
454 escaped_path = g_uri_escape_string (filename,
455 G_URI_RESERVED_CHARS_ALLOWED_IN_PATH_ELEMENT "/",
457 parse_name = g_strconcat ("file://",
458 (*escaped_path != '/') ? "/" : "",
462 g_free (escaped_path);
464 if (free_utf8_filename)
465 g_free (utf8_filename);
472 g_local_file_get_parent (GFile *file)
474 GLocalFile *local = G_LOCAL_FILE (file);
475 const char *non_root;
480 non_root = g_path_skip_root (local->filename);
484 dirname = g_path_get_dirname (local->filename);
485 parent = _g_local_file_new (dirname);
491 g_local_file_dup (GFile *file)
493 GLocalFile *local = G_LOCAL_FILE (file);
495 return _g_local_file_new (local->filename);
499 g_local_file_hash (GFile *file)
501 GLocalFile *local = G_LOCAL_FILE (file);
503 return g_str_hash (local->filename);
507 g_local_file_equal (GFile *file1,
510 GLocalFile *local1 = G_LOCAL_FILE (file1);
511 GLocalFile *local2 = G_LOCAL_FILE (file2);
513 return g_str_equal (local1->filename, local2->filename);
517 match_prefix (const char *path,
522 prefix_len = strlen (prefix);
523 if (strncmp (path, prefix, prefix_len) != 0)
526 /* Handle the case where prefix is the root, so that
527 * the IS_DIR_SEPRARATOR check below works */
528 if (prefix_len > 0 &&
529 G_IS_DIR_SEPARATOR (prefix[prefix_len-1]))
532 return path + prefix_len;
536 g_local_file_prefix_matches (GFile *parent,
539 GLocalFile *parent_local = G_LOCAL_FILE (parent);
540 GLocalFile *descendant_local = G_LOCAL_FILE (descendant);
541 const char *remainder;
543 remainder = match_prefix (descendant_local->filename, parent_local->filename);
544 if (remainder != NULL && G_IS_DIR_SEPARATOR (*remainder))
550 g_local_file_get_relative_path (GFile *parent,
553 GLocalFile *parent_local = G_LOCAL_FILE (parent);
554 GLocalFile *descendant_local = G_LOCAL_FILE (descendant);
555 const char *remainder;
557 remainder = match_prefix (descendant_local->filename, parent_local->filename);
559 if (remainder != NULL && G_IS_DIR_SEPARATOR (*remainder))
560 return g_strdup (remainder + 1);
565 g_local_file_resolve_relative_path (GFile *file,
566 const char *relative_path)
568 GLocalFile *local = G_LOCAL_FILE (file);
572 if (g_path_is_absolute (relative_path))
573 return _g_local_file_new (relative_path);
575 filename = g_build_filename (local->filename, relative_path, NULL);
576 child = _g_local_file_new (filename);
582 static GFileEnumerator *
583 g_local_file_enumerate_children (GFile *file,
584 const char *attributes,
585 GFileQueryInfoFlags flags,
586 GCancellable *cancellable,
589 GLocalFile *local = G_LOCAL_FILE (file);
590 return _g_local_file_enumerator_new (local,
596 g_local_file_get_child_for_display_name (GFile *file,
597 const char *display_name,
603 basename = g_filename_from_utf8 (display_name, -1, NULL, NULL, NULL);
604 if (basename == NULL)
606 g_set_error (error, G_IO_ERROR,
607 G_IO_ERROR_INVALID_FILENAME,
608 _("Invalid filename %s"), display_name);
612 new_file = g_file_get_child (file, basename);
620 get_fs_type (long f_type)
622 g_print ("get fstype for %ld\n", f_type);
624 /* filesystem ids taken from linux manpage */
729 G_LOCK_DEFINE_STATIC(mount_info_hash);
730 static GHashTable *mount_info_hash = NULL;
731 static guint64 mount_info_hash_cache_time = 0;
734 MOUNT_INFO_READONLY = 1<<0
738 device_equal (gconstpointer v1,
741 return *(dev_t *)v1 == *(dev_t *)v2;
745 device_hash (gconstpointer v)
747 return (guint) *(dev_t *)v;
751 get_mount_info (GFileInfo *fs_info,
753 GFileAttributeMatcher *matcher)
757 gpointer info_as_ptr;
761 GUnixMountEntry *mount;
764 if (g_lstat (path, &buf) != 0)
767 G_LOCK (mount_info_hash);
769 if (mount_info_hash == NULL)
770 mount_info_hash = g_hash_table_new_full (device_hash, device_equal,
774 if (g_unix_mounts_changed_since (mount_info_hash_cache_time))
775 g_hash_table_remove_all (mount_info_hash);
777 got_info = g_hash_table_lookup_extended (mount_info_hash,
782 G_UNLOCK (mount_info_hash);
784 mount_info = GPOINTER_TO_UINT (info_as_ptr);
790 mountpoint = find_mountpoint_for (path, buf.st_dev);
791 if (mountpoint == NULL)
792 mountpoint = g_strdup ("/");
794 mount = g_unix_mount_at (mountpoint, &cache_time);
797 if (g_unix_mount_is_readonly (mount))
798 mount_info |= MOUNT_INFO_READONLY;
800 g_unix_mount_free (mount);
805 dev = g_new0 (dev_t, 1);
808 G_LOCK (mount_info_hash);
809 mount_info_hash_cache_time = cache_time;
810 g_hash_table_insert (mount_info_hash, dev, GUINT_TO_POINTER (mount_info));
811 G_UNLOCK (mount_info_hash);
814 if (mount_info & MOUNT_INFO_READONLY)
815 g_file_info_set_attribute_boolean (fs_info, G_FILE_ATTRIBUTE_FILESYSTEM_READONLY, TRUE);
823 is_xp_or_later (void)
825 static int result = -1;
830 OSVERSIONINFOEX ver_info = {0};
831 DWORDLONG cond_mask = 0;
832 int op = VER_GREATER_EQUAL;
834 ver_info.dwOSVersionInfoSize = sizeof ver_info;
835 ver_info.dwMajorVersion = 5;
836 ver_info.dwMinorVersion = 1;
838 VER_SET_CONDITION (cond_mask, VER_MAJORVERSION, op);
839 VER_SET_CONDITION (cond_mask, VER_MINORVERSION, op);
841 result = VerifyVersionInfo (&ver_info,
842 VER_MAJORVERSION | VER_MINORVERSION,
845 result = ((DWORD)(LOBYTE (LOWORD (GetVersion ())))) >= 5;
853 get_volume_for_path (const char *path)
859 wpath = g_utf8_to_utf16 (path, -1, NULL, NULL, NULL);
860 result = g_new (wchar_t, MAX_PATH);
862 if (!GetVolumePathNameW (wpath, result, MAX_PATH))
864 char *msg = g_win32_error_message (GetLastError ());
865 g_critical ("GetVolumePathName failed: %s", msg);
872 len = wcslen (result);
873 if (len > 0 && result[len-1] != L'\\')
875 result = g_renew (wchar_t, result, len + 2);
885 find_mountpoint_for (const char *file, dev_t dev)
890 wpath = get_volume_for_path (file);
894 utf8_path = g_utf16_to_utf8 (wpath, -1, NULL, NULL, NULL);
901 get_filesystem_readonly (GFileInfo *info,
906 rootdir = get_volume_for_path (path);
910 if (is_xp_or_later ())
913 if (GetVolumeInformationW (rootdir, NULL, 0, NULL, NULL, &flags, NULL, 0))
914 g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_FILESYSTEM_READONLY,
915 (flags & FILE_READ_ONLY_VOLUME) != 0);
919 if (GetDriveTypeW (rootdir) == DRIVE_CDROM)
920 g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_FILESYSTEM_READONLY, TRUE);
927 #endif /* G_OS_WIN32 */
930 g_local_file_query_filesystem_info (GFile *file,
931 const char *attributes,
932 GCancellable *cancellable,
935 GLocalFile *local = G_LOCAL_FILE (file);
937 int statfs_result = 0;
943 struct statfs statfs_buffer;
944 #elif defined(USE_STATVFS)
945 struct statvfs statfs_buffer;
948 GFileAttributeMatcher *attribute_matcher;
950 g_print ("g_local_file_query_filesystem_info\n");
956 statfs_result = statfs (local->filename, &statfs_buffer);
957 #elif STATFS_ARGS == 4
958 statfs_result = statfs (local->filename, &statfs_buffer,
959 sizeof (statfs_buffer), 0);
961 block_size = statfs_buffer.f_bsize;
963 #if defined(__linux__)
964 /* ncpfs does not know the amount of available and free space *
965 * assuming ncpfs is linux specific, if you are on a non-linux platform
966 * where ncpfs is available, please file a bug about it on bugzilla.gnome.org
968 if (statfs_buffer.f_bavail == 0 && statfs_buffer.f_bfree == 0 &&
969 /* linux/ncp_fs.h: NCP_SUPER_MAGIC == 0x564c */
970 statfs_buffer.f_type == 0x564c)
974 #elif defined(USE_STATVFS)
975 statfs_result = statvfs (local->filename, &statfs_buffer);
976 block_size = statfs_buffer.f_frsize;
979 if (statfs_result == -1)
983 g_set_error (error, G_IO_ERROR,
984 g_io_error_from_errno (errsv),
985 _("Error getting filesystem info: %s"),
990 info = g_file_info_new ();
992 attribute_matcher = g_file_attribute_matcher_new (attributes);
995 g_file_attribute_matcher_matches (attribute_matcher,
996 G_FILE_ATTRIBUTE_FILESYSTEM_FREE))
999 gchar *localdir = g_path_get_dirname (local->filename);
1000 wchar_t *wdirname = g_utf8_to_utf16 (localdir, -1, NULL, NULL, NULL);
1004 if (GetDiskFreeSpaceExW (wdirname, &li, NULL, NULL))
1005 g_file_info_set_attribute_uint64 (info, G_FILE_ATTRIBUTE_FILESYSTEM_FREE, (guint64)li.QuadPart);
1008 g_file_info_set_attribute_uint64 (info, G_FILE_ATTRIBUTE_FILESYSTEM_FREE, block_size * statfs_buffer.f_bavail);
1012 g_file_attribute_matcher_matches (attribute_matcher,
1013 G_FILE_ATTRIBUTE_FILESYSTEM_SIZE))
1016 gchar *localdir = g_path_get_dirname (local->filename);
1017 wchar_t *wdirname = g_utf8_to_utf16 (localdir, -1, NULL, NULL, NULL);
1021 if (GetDiskFreeSpaceExW (wdirname, NULL, &li, NULL))
1022 g_file_info_set_attribute_uint64 (info, G_FILE_ATTRIBUTE_FILESYSTEM_SIZE, (guint64)li.QuadPart);
1025 g_file_info_set_attribute_uint64 (info, G_FILE_ATTRIBUTE_FILESYSTEM_SIZE, block_size * statfs_buffer.f_blocks);
1029 #if defined(HAVE_STRUCT_STATFS_F_FSTYPENAME)
1030 fstype = g_strdup(statfs_buffer.f_fstypename);
1031 g_print ("using f_fstypename %s\n", fstype);
1033 fstype = get_fs_type (statfs_buffer.f_type);
1034 g_print ("using f_type %s\n", fstype);
1037 #elif defined(USE_STATVFS) && defined(HAVE_STRUCT_STATVFS_F_BASETYPE)
1038 fstype = g_strdup(statfs_buffer.f_basetype);
1043 g_file_attribute_matcher_matches (attribute_matcher,
1044 G_FILE_ATTRIBUTE_FILESYSTEM_TYPE))
1045 g_file_info_set_attribute_string (info, G_FILE_ATTRIBUTE_FILESYSTEM_TYPE, fstype);
1048 if (g_file_attribute_matcher_matches (attribute_matcher,
1049 G_FILE_ATTRIBUTE_FILESYSTEM_READONLY))
1052 get_filesystem_readonly (info, local->filename);
1054 get_mount_info (info, local->filename, attribute_matcher);
1058 g_file_attribute_matcher_unref (attribute_matcher);
1064 g_local_file_find_enclosing_mount (GFile *file,
1065 GCancellable *cancellable,
1068 GLocalFile *local = G_LOCAL_FILE (file);
1073 if (g_lstat (local->filename, &buf) != 0)
1075 g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
1076 /* Translators: This is an error message when trying to
1077 * find the enclosing (user visible) mount of a file, but
1079 _("Containing mount does not exist"));
1083 mountpoint = find_mountpoint_for (local->filename, buf.st_dev);
1084 if (mountpoint == NULL)
1086 g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
1087 /* Translators: This is an error message when trying to
1088 * find the enclosing (user visible) mount of a file, but
1090 _("Containing mount does not exist"));
1094 mount = _g_mount_get_for_mount_path (mountpoint, cancellable);
1095 g_free (mountpoint);
1099 g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
1100 /* Translators: This is an error message when trying to find
1101 * the enclosing (user visible) mount of a file, but none
1103 _("Containing mount does not exist"));
1108 g_local_file_set_display_name (GFile *file,
1109 const char *display_name,
1110 GCancellable *cancellable,
1113 GLocalFile *local, *new_local;
1114 GFile *new_file, *parent;
1115 struct stat statbuf;
1118 parent = g_file_get_parent (file);
1121 g_set_error_literal (error, G_IO_ERROR,
1123 _("Can't rename root directory"));
1127 new_file = g_file_get_child_for_display_name (parent, display_name, error);
1128 g_object_unref (parent);
1130 if (new_file == NULL)
1132 local = G_LOCAL_FILE (file);
1133 new_local = G_LOCAL_FILE (new_file);
1135 if (g_lstat (new_local->filename, &statbuf) == -1)
1139 if (errsv != ENOENT)
1141 g_set_error (error, G_IO_ERROR,
1142 g_io_error_from_errno (errsv),
1143 _("Error renaming file: %s"),
1144 g_strerror (errsv));
1150 g_set_error_literal (error, G_IO_ERROR,
1152 _("Can't rename file, filename already exist"));
1156 if (g_rename (local->filename, new_local->filename) == -1)
1160 if (errsv == EINVAL)
1161 /* We can't get a rename file into itself error herer,
1162 so this must be an invalid filename, on e.g. FAT */
1163 g_set_error_literal (error, G_IO_ERROR,
1164 G_IO_ERROR_INVALID_FILENAME,
1165 _("Invalid filename"));
1167 g_set_error (error, G_IO_ERROR,
1168 g_io_error_from_errno (errsv),
1169 _("Error renaming file: %s"),
1170 g_strerror (errsv));
1171 g_object_unref (new_file);
1179 g_local_file_query_info (GFile *file,
1180 const char *attributes,
1181 GFileQueryInfoFlags flags,
1182 GCancellable *cancellable,
1185 GLocalFile *local = G_LOCAL_FILE (file);
1187 GFileAttributeMatcher *matcher;
1188 char *basename, *dirname;
1189 GLocalParentFileInfo parent_info;
1191 matcher = g_file_attribute_matcher_new (attributes);
1193 basename = g_path_get_basename (local->filename);
1195 dirname = g_path_get_dirname (local->filename);
1196 _g_local_file_info_get_parent_info (dirname, matcher, &parent_info);
1199 info = _g_local_file_info_get (basename, local->filename,
1200 matcher, flags, &parent_info,
1205 g_file_attribute_matcher_unref (matcher);
1210 static GFileAttributeInfoList *
1211 g_local_file_query_settable_attributes (GFile *file,
1212 GCancellable *cancellable,
1215 return g_file_attribute_info_list_ref (local_writable_attributes);
1218 static GFileAttributeInfoList *
1219 g_local_file_query_writable_namespaces (GFile *file,
1220 GCancellable *cancellable,
1223 return g_file_attribute_info_list_ref (local_writable_namespaces);
1227 g_local_file_set_attribute (GFile *file,
1228 const char *attribute,
1229 GFileAttributeType type,
1231 GFileQueryInfoFlags flags,
1232 GCancellable *cancellable,
1235 GLocalFile *local = G_LOCAL_FILE (file);
1237 return _g_local_file_info_set_attribute (local->filename,
1247 g_local_file_set_attributes_from_info (GFile *file,
1249 GFileQueryInfoFlags flags,
1250 GCancellable *cancellable,
1253 GLocalFile *local = G_LOCAL_FILE (file);
1254 int res, chained_res;
1255 GFileIface *default_iface;
1257 res = _g_local_file_info_set_attributes (local->filename,
1263 error = NULL; /* Don't write over error if further errors */
1265 default_iface = g_type_default_interface_peek (G_TYPE_FILE);
1267 chained_res = (default_iface->set_attributes_from_info) (file, info, flags, cancellable, error);
1269 return res && chained_res;
1272 static GFileInputStream *
1273 g_local_file_read (GFile *file,
1274 GCancellable *cancellable,
1277 GLocalFile *local = G_LOCAL_FILE (file);
1281 fd = g_open (local->filename, O_RDONLY|O_BINARY, 0);
1286 g_set_error (error, G_IO_ERROR,
1287 g_io_error_from_errno (errsv),
1288 _("Error opening file: %s"),
1289 g_strerror (errsv));
1293 if (fstat(fd, &buf) == 0 && S_ISDIR (buf.st_mode))
1296 g_set_error_literal (error, G_IO_ERROR,
1297 G_IO_ERROR_IS_DIRECTORY,
1298 _("Can't open directory"));
1302 return _g_local_file_input_stream_new (fd);
1305 static GFileOutputStream *
1306 g_local_file_append_to (GFile *file,
1307 GFileCreateFlags flags,
1308 GCancellable *cancellable,
1311 return _g_local_file_output_stream_append (G_LOCAL_FILE (file)->filename,
1312 flags, cancellable, error);
1315 static GFileOutputStream *
1316 g_local_file_create (GFile *file,
1317 GFileCreateFlags flags,
1318 GCancellable *cancellable,
1321 return _g_local_file_output_stream_create (G_LOCAL_FILE (file)->filename,
1322 flags, cancellable, error);
1325 static GFileOutputStream *
1326 g_local_file_replace (GFile *file,
1328 gboolean make_backup,
1329 GFileCreateFlags flags,
1330 GCancellable *cancellable,
1333 return _g_local_file_output_stream_replace (G_LOCAL_FILE (file)->filename,
1334 etag, make_backup, flags,
1335 cancellable, error);
1340 g_local_file_delete (GFile *file,
1341 GCancellable *cancellable,
1344 GLocalFile *local = G_LOCAL_FILE (file);
1346 if (g_remove (local->filename) == -1)
1350 /* Posix allows EEXIST too, but the more sane error
1351 is G_IO_ERROR_NOT_FOUND, and it's what nautilus
1353 if (errsv == EEXIST)
1356 g_set_error (error, G_IO_ERROR,
1357 g_io_error_from_errno (errsv),
1358 _("Error removing file: %s"),
1359 g_strerror (errsv));
1367 strip_trailing_slashes (const char *path)
1372 path_copy = g_strdup (path);
1373 len = strlen (path_copy);
1374 while (len > 1 && path_copy[len-1] == '/')
1375 path_copy[--len] = 0;
1381 expand_symlink (const char *link)
1383 char *resolved, *canonical, *parent, *link2;
1384 char symlink_value[4096];
1392 res = readlink (link, symlink_value, sizeof (symlink_value) - 1);
1395 return g_strdup (link);
1396 symlink_value[res] = 0;
1399 if (g_path_is_absolute (symlink_value))
1400 return canonicalize_filename (symlink_value);
1403 link2 = strip_trailing_slashes (link);
1404 parent = g_path_get_dirname (link2);
1407 resolved = g_build_filename (parent, symlink_value, NULL);
1410 canonical = canonicalize_filename (resolved);
1419 get_parent (const char *path,
1423 struct stat parent_stat;
1427 path_copy = strip_trailing_slashes (path);
1429 parent = g_path_get_dirname (path_copy);
1430 if (strcmp (parent, ".") == 0 ||
1431 strcmp (parent, path_copy) == 0)
1441 if (g_lstat (parent, &parent_stat) != 0)
1447 if (S_ISLNK (parent_stat.st_mode))
1450 parent = expand_symlink (parent);
1455 if (num_recursions > 12)
1460 } while (S_ISLNK (parent_stat.st_mode));
1462 *parent_dev = parent_stat.st_dev;
1468 expand_all_symlinks (const char *path)
1470 char *parent, *parent_expanded;
1471 char *basename, *res;
1474 parent = get_parent (path, &parent_dev);
1477 parent_expanded = expand_all_symlinks (parent);
1479 basename = g_path_get_basename (path);
1480 res = g_build_filename (parent_expanded, basename, NULL);
1482 g_free (parent_expanded);
1485 res = g_strdup (path);
1493 find_mountpoint_for (const char *file,
1497 dev_t dir_dev, parent_dev;
1499 dir = g_strdup (file);
1504 parent = get_parent (dir, &parent_dev);
1508 if (parent_dev != dir_dev)
1520 find_topdir_for (const char *file)
1525 dir = get_parent (file, &dir_dev);
1529 return find_mountpoint_for (dir, dir_dev);
1533 get_unique_filename (const char *basename,
1539 return g_strdup (basename);
1541 dot = strchr (basename, '.');
1543 return g_strdup_printf ("%.*s.%d%s", (int)(dot - basename), basename, id, dot);
1545 return g_strdup_printf ("%s.%d", basename, id);
1549 path_has_prefix (const char *path,
1557 prefix_len = strlen (prefix);
1559 if (strncmp (path, prefix, prefix_len) == 0 &&
1560 (prefix_len == 0 || /* empty prefix always matches */
1561 prefix[prefix_len - 1] == '/' || /* last char in prefix was a /, so it must be in path too */
1562 path[prefix_len] == 0 ||
1563 path[prefix_len] == '/'))
1570 try_make_relative (const char *path,
1573 char *path2, *base2;
1576 path2 = expand_all_symlinks (path);
1577 base2 = expand_all_symlinks (base);
1580 if (path_has_prefix (path2, base2))
1582 relative = path2 + strlen (base2);
1583 while (*relative == '/')
1585 relative = g_strdup (relative);
1593 /* Failed, use abs path */
1594 return g_strdup (path);
1598 escape_trash_name (char *name)
1601 const gchar hex[16] = "0123456789ABCDEF";
1603 str = g_string_new ("");
1611 if (g_ascii_isprint (c))
1612 g_string_append_c (str, c);
1615 g_string_append_c (str, '%');
1616 g_string_append_c (str, hex[((guchar)c) >> 4]);
1617 g_string_append_c (str, hex[((guchar)c) & 0xf]);
1621 return g_string_free (str, FALSE);
1625 _g_local_file_has_trash_dir (const char *dirname, dev_t dir_dev)
1627 static gsize home_dev_set = 0;
1628 static dev_t home_dev;
1629 char *topdir, *globaldir, *trashdir, *tmpname;
1632 struct stat global_stat, trash_stat;
1636 if (g_once_init_enter (&home_dev_set))
1638 struct stat home_stat;
1640 g_stat (g_get_home_dir (), &home_stat);
1641 home_dev = home_stat.st_dev;
1642 g_once_init_leave (&home_dev_set, 1);
1645 /* Assume we can trash to the home */
1646 if (dir_dev == home_dev)
1649 topdir = find_mountpoint_for (dirname, dir_dev);
1653 globaldir = g_build_filename (topdir, ".Trash", NULL);
1654 statres = g_lstat (globaldir, &global_stat);
1655 if (g_lstat (globaldir, &global_stat) == 0 &&
1656 S_ISDIR (global_stat.st_mode) &&
1657 (global_stat.st_mode & S_ISVTX) != 0)
1659 /* got a toplevel sysadmin created dir, assume we
1660 * can trash to it (we should be able to create a dir)
1661 * This fails for the FAT case where the ownership of
1662 * that dir would be wrong though..
1670 /* No global trash dir, or it failed the tests, fall back to $topdir/.Trash-$uid */
1672 g_snprintf (uid_str, sizeof (uid_str), "%lu", (unsigned long) uid);
1674 tmpname = g_strdup_printf (".Trash-%s", uid_str);
1675 trashdir = g_build_filename (topdir, tmpname, NULL);
1678 if (g_lstat (trashdir, &trash_stat) == 0)
1683 S_ISDIR (trash_stat.st_mode) &&
1684 trash_stat.st_uid == uid;
1688 /* User specific trash didn't exist, can we create it? */
1689 res = g_access (topdir, W_OK) == 0;
1698 g_local_file_trash (GFile *file,
1699 GCancellable *cancellable,
1702 GLocalFile *local = G_LOCAL_FILE (file);
1703 struct stat file_stat, home_stat;
1704 const char *homedir;
1705 char *trashdir, *topdir, *infodir, *filesdir;
1706 char *basename, *trashname, *trashfile, *infoname, *infofile;
1707 char *original_name, *original_name_escaped;
1710 gboolean is_homedir_trash;
1711 char delete_time[32];
1713 struct stat trash_stat, global_stat;
1714 char *dirname, *globaldir;
1716 if (g_lstat (local->filename, &file_stat) != 0)
1720 g_set_error (error, G_IO_ERROR,
1721 g_io_error_from_errno (errsv),
1722 _("Error trashing file: %s"),
1723 g_strerror (errsv));
1727 homedir = g_get_home_dir ();
1728 g_stat (homedir, &home_stat);
1730 is_homedir_trash = FALSE;
1732 if (file_stat.st_dev == home_stat.st_dev)
1734 is_homedir_trash = TRUE;
1736 trashdir = g_build_filename (g_get_user_data_dir (), "Trash", NULL);
1737 if (g_mkdir_with_parents (trashdir, 0700) < 0)
1742 display_name = g_filename_display_name (trashdir);
1743 g_set_error (error, G_IO_ERROR,
1744 g_io_error_from_errno (errsv),
1745 _("Unable to create trash dir %s: %s"),
1746 display_name, g_strerror (errsv));
1747 g_free (display_name);
1751 topdir = g_strdup (g_get_user_data_dir ());
1759 g_snprintf (uid_str, sizeof (uid_str), "%lu", (unsigned long)uid);
1761 topdir = find_topdir_for (local->filename);
1764 g_set_error_literal (error, G_IO_ERROR,
1765 G_IO_ERROR_NOT_SUPPORTED,
1766 _("Unable to find toplevel directory for trash"));
1770 /* Try looking for global trash dir $topdir/.Trash/$uid */
1771 globaldir = g_build_filename (topdir, ".Trash", NULL);
1772 if (g_lstat (globaldir, &global_stat) == 0 &&
1773 S_ISDIR (global_stat.st_mode) &&
1774 (global_stat.st_mode & S_ISVTX) != 0)
1776 trashdir = g_build_filename (globaldir, uid_str, NULL);
1778 if (g_lstat (trashdir, &trash_stat) == 0)
1780 if (!S_ISDIR (trash_stat.st_mode) ||
1781 trash_stat.st_uid != uid)
1783 /* Not a directory or not owned by user, ignore */
1788 else if (g_mkdir (trashdir, 0700) == -1)
1796 if (trashdir == NULL)
1798 gboolean tried_create;
1800 /* No global trash dir, or it failed the tests, fall back to $topdir/.Trash-$uid */
1801 dirname = g_strdup_printf (".Trash-%s", uid_str);
1802 trashdir = g_build_filename (topdir, dirname, NULL);
1805 tried_create = FALSE;
1808 if (g_lstat (trashdir, &trash_stat) == 0)
1810 if (!S_ISDIR (trash_stat.st_mode) ||
1811 trash_stat.st_uid != uid)
1813 /* Remove the failed directory */
1815 g_remove (trashdir);
1817 /* Not a directory or not owned by user, ignore */
1824 if (!tried_create &&
1825 g_mkdir (trashdir, 0700) != -1)
1827 /* Ensure that the created dir has the right uid etc.
1828 This might fail on e.g. a FAT dir */
1829 tried_create = TRUE;
1840 if (trashdir == NULL)
1843 g_set_error_literal (error, G_IO_ERROR,
1844 G_IO_ERROR_NOT_SUPPORTED,
1845 _("Unable to find or create trash directory"));
1850 /* Trashdir points to the trash dir with the "info" and "files" subdirectories */
1852 infodir = g_build_filename (trashdir, "info", NULL);
1853 filesdir = g_build_filename (trashdir, "files", NULL);
1856 /* Make sure we have the subdirectories */
1857 if ((g_mkdir (infodir, 0700) == -1 && errno != EEXIST) ||
1858 (g_mkdir (filesdir, 0700) == -1 && errno != EEXIST))
1863 g_set_error_literal (error, G_IO_ERROR,
1864 G_IO_ERROR_NOT_SUPPORTED,
1865 _("Unable to find or create trash directory"));
1869 basename = g_path_get_basename (local->filename);
1877 trashname = get_unique_filename (basename, i++);
1878 infoname = g_strconcat (trashname, ".trashinfo", NULL);
1879 infofile = g_build_filename (infodir, infoname, NULL);
1882 fd = open (infofile, O_CREAT | O_EXCL, 0666);
1883 } while (fd == -1 && errno == EEXIST);
1897 g_set_error (error, G_IO_ERROR,
1898 g_io_error_from_errno (errsv),
1899 _("Unable to create trashing info file: %s"),
1900 g_strerror (errsv));
1906 /* TODO: Maybe we should verify that you can delete the file from the trash
1907 before moving it? OTOH, that is hard, as it needs a recursive scan */
1909 trashfile = g_build_filename (filesdir, trashname, NULL);
1913 if (g_rename (local->filename, trashfile) == -1)
1922 g_set_error (error, G_IO_ERROR,
1923 g_io_error_from_errno (errsv),
1924 _("Unable to trash file: %s"),
1925 g_strerror (errsv));
1931 /* TODO: Do we need to update mtime/atime here after the move? */
1933 /* Use absolute names for homedir */
1934 if (is_homedir_trash)
1935 original_name = g_strdup (local->filename);
1937 original_name = try_make_relative (local->filename, topdir);
1938 original_name_escaped = escape_trash_name (original_name);
1940 g_free (original_name);
1947 localtime_r (&t, &now);
1949 strftime(delete_time, sizeof (delete_time), "%Y-%m-%dT%H:%M:%S", &now);
1952 data = g_strdup_printf ("[Trash Info]\nPath=%s\nDeletionDate=%s\n",
1953 original_name_escaped, delete_time);
1955 g_file_set_contents (infofile, data, -1, NULL);
1959 g_free (original_name_escaped);
1964 #else /* G_OS_WIN32 */
1966 _g_local_file_has_trash_dir (const char *dirname, dev_t dir_dev)
1968 return FALSE; /* XXX ??? */
1972 g_local_file_trash (GFile *file,
1973 GCancellable *cancellable,
1976 GLocalFile *local = G_LOCAL_FILE (file);
1977 SHFILEOPSTRUCTW op = {0};
1982 wfilename = g_utf8_to_utf16 (local->filename, -1, NULL, &len, NULL);
1983 /* SHFILEOPSTRUCT.pFrom is double-zero-terminated */
1984 wfilename = g_renew (wchar_t, wfilename, len + 2);
1985 wfilename[len + 1] = 0;
1987 op.wFunc = FO_DELETE;
1988 op.pFrom = wfilename;
1989 op.fFlags = FOF_ALLOWUNDO;
1991 success = SHFileOperationW (&op) == 0;
1993 if (success && op.fAnyOperationsAborted)
1995 if (cancellable && !g_cancellable_is_cancelled (cancellable))
1996 g_cancellable_cancel (cancellable);
1997 g_set_error (error, G_IO_ERROR,
1998 G_IO_ERROR_CANCELLED,
1999 _("Unable to trash file: %s"),
2000 _("Operation was cancelled"));
2004 g_set_error (error, G_IO_ERROR,
2006 _("Unable to trash file: %s"),
2007 _("internal error"));
2012 #endif /* G_OS_WIN32 */
2015 g_local_file_make_directory (GFile *file,
2016 GCancellable *cancellable,
2019 GLocalFile *local = G_LOCAL_FILE (file);
2021 if (g_mkdir (local->filename, 0777) == -1)
2025 if (errsv == EINVAL)
2026 /* This must be an invalid filename, on e.g. FAT */
2027 g_set_error_literal (error, G_IO_ERROR,
2028 G_IO_ERROR_INVALID_FILENAME,
2029 _("Invalid filename"));
2031 g_set_error (error, G_IO_ERROR,
2032 g_io_error_from_errno (errsv),
2033 _("Error creating directory: %s"),
2034 g_strerror (errsv));
2042 g_local_file_make_symbolic_link (GFile *file,
2043 const char *symlink_value,
2044 GCancellable *cancellable,
2048 GLocalFile *local = G_LOCAL_FILE (file);
2050 if (symlink (symlink_value, local->filename) == -1)
2054 if (errsv == EINVAL)
2055 /* This must be an invalid filename, on e.g. FAT */
2056 g_set_error_literal (error, G_IO_ERROR,
2057 G_IO_ERROR_INVALID_FILENAME,
2058 _("Invalid filename"));
2060 g_set_error (error, G_IO_ERROR,
2061 g_io_error_from_errno (errsv),
2062 _("Error making symbolic link: %s"),
2063 g_strerror (errsv));
2068 g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, "Symlinks not supported");
2075 g_local_file_copy (GFile *source,
2077 GFileCopyFlags flags,
2078 GCancellable *cancellable,
2079 GFileProgressCallback progress_callback,
2080 gpointer progress_callback_data,
2083 /* Fall back to default copy */
2084 g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, "Copy not supported");
2089 g_local_file_move (GFile *source,
2091 GFileCopyFlags flags,
2092 GCancellable *cancellable,
2093 GFileProgressCallback progress_callback,
2094 gpointer progress_callback_data,
2097 GLocalFile *local_source, *local_destination;
2098 struct stat statbuf;
2099 gboolean destination_exist, source_is_dir;
2104 if (!G_IS_LOCAL_FILE (source) ||
2105 !G_IS_LOCAL_FILE (destination))
2107 /* Fall back to default move */
2108 g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, "Move not supported");
2112 local_source = G_LOCAL_FILE (source);
2113 local_destination = G_LOCAL_FILE (destination);
2115 res = g_lstat (local_source->filename, &statbuf);
2120 g_set_error (error, G_IO_ERROR,
2121 g_io_error_from_errno (errsv),
2122 _("Error moving file: %s"),
2123 g_strerror (errsv));
2127 source_is_dir = S_ISDIR (statbuf.st_mode);
2128 source_size = statbuf.st_size;
2130 destination_exist = FALSE;
2131 res = g_lstat (local_destination->filename, &statbuf);
2134 destination_exist = TRUE; /* Target file exists */
2136 if (flags & G_FILE_COPY_OVERWRITE)
2138 /* Always fail on dirs, even with overwrite */
2139 if (S_ISDIR (statbuf.st_mode))
2142 g_set_error_literal (error,
2144 G_IO_ERROR_WOULD_MERGE,
2145 _("Can't move directory over directory"));
2147 g_set_error_literal (error,
2149 G_IO_ERROR_IS_DIRECTORY,
2150 _("Can't copy over directory"));
2156 g_set_error_literal (error,
2159 _("Target file exists"));
2164 if (flags & G_FILE_COPY_BACKUP && destination_exist)
2166 backup_name = g_strconcat (local_destination->filename, "~", NULL);
2167 if (g_rename (local_destination->filename, backup_name) == -1)
2169 g_set_error_literal (error,
2171 G_IO_ERROR_CANT_CREATE_BACKUP,
2172 _("Backup file creation failed"));
2173 g_free (backup_name);
2176 g_free (backup_name);
2177 destination_exist = FALSE; /* It did, but no more */
2180 if (source_is_dir && destination_exist && (flags & G_FILE_COPY_OVERWRITE))
2182 /* Source is a dir, destination exists (and is not a dir, because that would have failed
2183 earlier), and we're overwriting. Manually remove the target so we can do the rename. */
2184 res = g_unlink (local_destination->filename);
2189 g_set_error (error, G_IO_ERROR,
2190 g_io_error_from_errno (errsv),
2191 _("Error removing target file: %s"),
2192 g_strerror (errsv));
2197 if (g_rename (local_source->filename, local_destination->filename) == -1)
2202 /* This will cause the fallback code to run */
2203 g_set_error_literal (error, G_IO_ERROR,
2204 G_IO_ERROR_NOT_SUPPORTED,
2205 _("Move between mounts not supported"));
2206 else if (errsv == EINVAL)
2207 /* This must be an invalid filename, on e.g. FAT, or
2208 we're trying to move the file into itself...
2209 We return invalid filename for both... */
2210 g_set_error_literal (error, G_IO_ERROR,
2211 G_IO_ERROR_INVALID_FILENAME,
2212 _("Invalid filename"));
2214 g_set_error (error, G_IO_ERROR,
2215 g_io_error_from_errno (errsv),
2216 _("Error moving file: %s"),
2217 g_strerror (errsv));
2221 /* Make sure we send full copied size */
2222 if (progress_callback)
2223 progress_callback (source_size, source_size, progress_callback_data);
2228 static GFileMonitor*
2229 g_local_file_monitor_dir (GFile *file,
2230 GFileMonitorFlags flags,
2231 GCancellable *cancellable,
2234 GLocalFile* local_file = G_LOCAL_FILE(file);
2235 return _g_local_directory_monitor_new (local_file->filename, flags, error);
2238 static GFileMonitor*
2239 g_local_file_monitor_file (GFile *file,
2240 GFileMonitorFlags flags,
2241 GCancellable *cancellable,
2244 GLocalFile* local_file = G_LOCAL_FILE(file);
2245 return _g_local_file_monitor_new (local_file->filename, flags, error);
2249 g_local_file_file_iface_init (GFileIface *iface)
2251 iface->dup = g_local_file_dup;
2252 iface->hash = g_local_file_hash;
2253 iface->equal = g_local_file_equal;
2254 iface->is_native = g_local_file_is_native;
2255 iface->has_uri_scheme = g_local_file_has_uri_scheme;
2256 iface->get_uri_scheme = g_local_file_get_uri_scheme;
2257 iface->get_basename = g_local_file_get_basename;
2258 iface->get_path = g_local_file_get_path;
2259 iface->get_uri = g_local_file_get_uri;
2260 iface->get_parse_name = g_local_file_get_parse_name;
2261 iface->get_parent = g_local_file_get_parent;
2262 iface->prefix_matches = g_local_file_prefix_matches;
2263 iface->get_relative_path = g_local_file_get_relative_path;
2264 iface->resolve_relative_path = g_local_file_resolve_relative_path;
2265 iface->get_child_for_display_name = g_local_file_get_child_for_display_name;
2266 iface->set_display_name = g_local_file_set_display_name;
2267 iface->enumerate_children = g_local_file_enumerate_children;
2268 iface->query_info = g_local_file_query_info;
2269 iface->query_filesystem_info = g_local_file_query_filesystem_info;
2270 iface->find_enclosing_mount = g_local_file_find_enclosing_mount;
2271 iface->query_settable_attributes = g_local_file_query_settable_attributes;
2272 iface->query_writable_namespaces = g_local_file_query_writable_namespaces;
2273 iface->set_attribute = g_local_file_set_attribute;
2274 iface->set_attributes_from_info = g_local_file_set_attributes_from_info;
2275 iface->read_fn = g_local_file_read;
2276 iface->append_to = g_local_file_append_to;
2277 iface->create = g_local_file_create;
2278 iface->replace = g_local_file_replace;
2279 iface->delete_file = g_local_file_delete;
2280 iface->trash = g_local_file_trash;
2281 iface->make_directory = g_local_file_make_directory;
2282 iface->make_symbolic_link = g_local_file_make_symbolic_link;
2283 iface->copy = g_local_file_copy;
2284 iface->move = g_local_file_move;
2285 iface->monitor_dir = g_local_file_monitor_dir;
2286 iface->monitor_file = g_local_file_monitor_file;