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);
249 /* This shouldn't really happen, as g_get_current_dir() should
250 return an absolute pathname, but bug 573843 shows this is
251 not always happening */
253 return g_build_filename (G_DIR_SEPARATOR_S, filename, NULL);
256 /* POSIX allows double slashes at the start to
257 * mean something special (as does windows too).
258 * So, "//" != "/", but more than two slashes
264 G_IS_DIR_SEPARATOR (*p);
271 memmove (start, start+i, strlen (start+i)+1);
277 if (p[0] == '.' && (p[1] == 0 || G_IS_DIR_SEPARATOR (p[1])))
279 memmove (p, p+1, strlen (p+1)+1);
281 else if (p[0] == '.' && p[1] == '.' && (p[2] == 0 || G_IS_DIR_SEPARATOR (p[2])))
284 /* Skip previous separator */
288 while (p > start && !G_IS_DIR_SEPARATOR (*p))
290 if (G_IS_DIR_SEPARATOR (*p))
291 *p++ = G_DIR_SEPARATOR;
292 memmove (p, q, strlen (q)+1);
296 /* Skip until next separator */
297 while (*p != 0 && !G_IS_DIR_SEPARATOR (*p))
302 /* Canonicalize one separator */
303 *p++ = G_DIR_SEPARATOR;
307 /* Remove additional separators */
309 while (*q && G_IS_DIR_SEPARATOR (*q))
313 memmove (p, q, strlen (q)+1);
316 /* Remove trailing slashes */
317 if (p > start && G_IS_DIR_SEPARATOR (*(p-1)))
325 * @filename: filename of the file to create.
327 * Returns: new local #GFile.
330 _g_local_file_new (const char *filename)
334 local = g_object_new (G_TYPE_LOCAL_FILE, NULL);
335 local->filename = canonicalize_filename (filename);
337 return G_FILE (local);
341 g_local_file_is_native (GFile *file)
347 g_local_file_has_uri_scheme (GFile *file,
348 const char *uri_scheme)
350 return g_ascii_strcasecmp (uri_scheme, "file") == 0;
354 g_local_file_get_uri_scheme (GFile *file)
356 return g_strdup ("file");
360 g_local_file_get_basename (GFile *file)
362 return g_path_get_basename (G_LOCAL_FILE (file)->filename);
366 g_local_file_get_path (GFile *file)
368 return g_strdup (G_LOCAL_FILE (file)->filename);
372 g_local_file_get_uri (GFile *file)
374 return g_filename_to_uri (G_LOCAL_FILE (file)->filename, NULL, NULL);
378 get_filename_charset (const gchar **filename_charset)
380 const gchar **charsets;
383 is_utf8 = g_get_filename_charsets (&charsets);
385 if (filename_charset)
386 *filename_charset = charsets[0];
392 name_is_valid_for_display (const char *string,
393 gboolean is_valid_utf8)
397 if (!is_valid_utf8 &&
398 !g_utf8_validate (string, -1, NULL))
401 while ((c = *string++) != 0)
403 if (g_ascii_iscntrl (c))
411 g_local_file_get_parse_name (GFile *file)
413 const char *filename;
415 const gchar *charset;
417 char *roundtripped_filename;
418 gboolean free_utf8_filename;
419 gboolean is_valid_utf8;
422 filename = G_LOCAL_FILE (file)->filename;
423 if (get_filename_charset (&charset))
425 utf8_filename = (char *)filename;
426 free_utf8_filename = FALSE;
427 is_valid_utf8 = FALSE; /* Can't guarantee this */
431 utf8_filename = g_convert (filename, -1,
432 "UTF-8", charset, NULL, NULL, NULL);
433 free_utf8_filename = TRUE;
434 is_valid_utf8 = TRUE;
436 if (utf8_filename != NULL)
438 /* Make sure we can roundtrip: */
439 roundtripped_filename = g_convert (utf8_filename, -1,
440 charset, "UTF-8", NULL, NULL, NULL);
442 if (roundtripped_filename == NULL ||
443 strcmp (utf8_filename, roundtripped_filename) != 0)
445 g_free (utf8_filename);
446 utf8_filename = NULL;
449 g_free (roundtripped_filename);
453 if (utf8_filename != NULL &&
454 name_is_valid_for_display (utf8_filename, is_valid_utf8))
456 if (free_utf8_filename)
457 parse_name = utf8_filename;
459 parse_name = g_strdup (utf8_filename);
463 escaped_path = g_uri_escape_string (filename,
464 G_URI_RESERVED_CHARS_ALLOWED_IN_PATH_ELEMENT "/",
466 parse_name = g_strconcat ("file://",
467 (*escaped_path != '/') ? "/" : "",
471 g_free (escaped_path);
473 if (free_utf8_filename)
474 g_free (utf8_filename);
481 g_local_file_get_parent (GFile *file)
483 GLocalFile *local = G_LOCAL_FILE (file);
484 const char *non_root;
489 non_root = g_path_skip_root (local->filename);
493 dirname = g_path_get_dirname (local->filename);
494 parent = _g_local_file_new (dirname);
500 g_local_file_dup (GFile *file)
502 GLocalFile *local = G_LOCAL_FILE (file);
504 return _g_local_file_new (local->filename);
508 g_local_file_hash (GFile *file)
510 GLocalFile *local = G_LOCAL_FILE (file);
512 return g_str_hash (local->filename);
516 g_local_file_equal (GFile *file1,
519 GLocalFile *local1 = G_LOCAL_FILE (file1);
520 GLocalFile *local2 = G_LOCAL_FILE (file2);
522 return g_str_equal (local1->filename, local2->filename);
526 match_prefix (const char *path,
531 prefix_len = strlen (prefix);
532 if (strncmp (path, prefix, prefix_len) != 0)
535 /* Handle the case where prefix is the root, so that
536 * the IS_DIR_SEPRARATOR check below works */
537 if (prefix_len > 0 &&
538 G_IS_DIR_SEPARATOR (prefix[prefix_len-1]))
541 return path + prefix_len;
545 g_local_file_prefix_matches (GFile *parent,
548 GLocalFile *parent_local = G_LOCAL_FILE (parent);
549 GLocalFile *descendant_local = G_LOCAL_FILE (descendant);
550 const char *remainder;
552 remainder = match_prefix (descendant_local->filename, parent_local->filename);
553 if (remainder != NULL && G_IS_DIR_SEPARATOR (*remainder))
559 g_local_file_get_relative_path (GFile *parent,
562 GLocalFile *parent_local = G_LOCAL_FILE (parent);
563 GLocalFile *descendant_local = G_LOCAL_FILE (descendant);
564 const char *remainder;
566 remainder = match_prefix (descendant_local->filename, parent_local->filename);
568 if (remainder != NULL && G_IS_DIR_SEPARATOR (*remainder))
569 return g_strdup (remainder + 1);
574 g_local_file_resolve_relative_path (GFile *file,
575 const char *relative_path)
577 GLocalFile *local = G_LOCAL_FILE (file);
581 if (g_path_is_absolute (relative_path))
582 return _g_local_file_new (relative_path);
584 filename = g_build_filename (local->filename, relative_path, NULL);
585 child = _g_local_file_new (filename);
591 static GFileEnumerator *
592 g_local_file_enumerate_children (GFile *file,
593 const char *attributes,
594 GFileQueryInfoFlags flags,
595 GCancellable *cancellable,
598 GLocalFile *local = G_LOCAL_FILE (file);
599 return _g_local_file_enumerator_new (local,
605 g_local_file_get_child_for_display_name (GFile *file,
606 const char *display_name,
612 basename = g_filename_from_utf8 (display_name, -1, NULL, NULL, NULL);
613 if (basename == NULL)
615 g_set_error (error, G_IO_ERROR,
616 G_IO_ERROR_INVALID_FILENAME,
617 _("Invalid filename %s"), display_name);
621 new_file = g_file_get_child (file, basename);
629 get_fs_type (long f_type)
631 /* filesystem ids taken from linux manpage */
736 G_LOCK_DEFINE_STATIC(mount_info_hash);
737 static GHashTable *mount_info_hash = NULL;
738 static guint64 mount_info_hash_cache_time = 0;
741 MOUNT_INFO_READONLY = 1<<0
745 device_equal (gconstpointer v1,
748 return *(dev_t *)v1 == *(dev_t *)v2;
752 device_hash (gconstpointer v)
754 return (guint) *(dev_t *)v;
758 get_mount_info (GFileInfo *fs_info,
760 GFileAttributeMatcher *matcher)
764 gpointer info_as_ptr;
768 GUnixMountEntry *mount;
771 if (g_lstat (path, &buf) != 0)
774 G_LOCK (mount_info_hash);
776 if (mount_info_hash == NULL)
777 mount_info_hash = g_hash_table_new_full (device_hash, device_equal,
781 if (g_unix_mounts_changed_since (mount_info_hash_cache_time))
782 g_hash_table_remove_all (mount_info_hash);
784 got_info = g_hash_table_lookup_extended (mount_info_hash,
789 G_UNLOCK (mount_info_hash);
791 mount_info = GPOINTER_TO_UINT (info_as_ptr);
797 mountpoint = find_mountpoint_for (path, buf.st_dev);
798 if (mountpoint == NULL)
799 mountpoint = g_strdup ("/");
801 mount = g_unix_mount_at (mountpoint, &cache_time);
804 if (g_unix_mount_is_readonly (mount))
805 mount_info |= MOUNT_INFO_READONLY;
807 g_unix_mount_free (mount);
812 dev = g_new0 (dev_t, 1);
815 G_LOCK (mount_info_hash);
816 mount_info_hash_cache_time = cache_time;
817 g_hash_table_insert (mount_info_hash, dev, GUINT_TO_POINTER (mount_info));
818 G_UNLOCK (mount_info_hash);
821 if (mount_info & MOUNT_INFO_READONLY)
822 g_file_info_set_attribute_boolean (fs_info, G_FILE_ATTRIBUTE_FILESYSTEM_READONLY, TRUE);
830 is_xp_or_later (void)
832 static int result = -1;
837 OSVERSIONINFOEX ver_info = {0};
838 DWORDLONG cond_mask = 0;
839 int op = VER_GREATER_EQUAL;
841 ver_info.dwOSVersionInfoSize = sizeof ver_info;
842 ver_info.dwMajorVersion = 5;
843 ver_info.dwMinorVersion = 1;
845 VER_SET_CONDITION (cond_mask, VER_MAJORVERSION, op);
846 VER_SET_CONDITION (cond_mask, VER_MINORVERSION, op);
848 result = VerifyVersionInfo (&ver_info,
849 VER_MAJORVERSION | VER_MINORVERSION,
852 result = ((DWORD)(LOBYTE (LOWORD (GetVersion ())))) >= 5;
860 get_volume_for_path (const char *path)
866 wpath = g_utf8_to_utf16 (path, -1, NULL, NULL, NULL);
867 result = g_new (wchar_t, MAX_PATH);
869 if (!GetVolumePathNameW (wpath, result, MAX_PATH))
871 char *msg = g_win32_error_message (GetLastError ());
872 g_critical ("GetVolumePathName failed: %s", msg);
879 len = wcslen (result);
880 if (len > 0 && result[len-1] != L'\\')
882 result = g_renew (wchar_t, result, len + 2);
892 find_mountpoint_for (const char *file, dev_t dev)
897 wpath = get_volume_for_path (file);
901 utf8_path = g_utf16_to_utf8 (wpath, -1, NULL, NULL, NULL);
908 get_filesystem_readonly (GFileInfo *info,
913 rootdir = get_volume_for_path (path);
917 if (is_xp_or_later ())
920 if (GetVolumeInformationW (rootdir, NULL, 0, NULL, NULL, &flags, NULL, 0))
921 g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_FILESYSTEM_READONLY,
922 (flags & FILE_READ_ONLY_VOLUME) != 0);
926 if (GetDriveTypeW (rootdir) == DRIVE_CDROM)
927 g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_FILESYSTEM_READONLY, TRUE);
934 #endif /* G_OS_WIN32 */
937 g_local_file_query_filesystem_info (GFile *file,
938 const char *attributes,
939 GCancellable *cancellable,
942 GLocalFile *local = G_LOCAL_FILE (file);
944 int statfs_result = 0;
950 struct statfs statfs_buffer;
951 #elif defined(USE_STATVFS)
952 struct statvfs statfs_buffer;
955 GFileAttributeMatcher *attribute_matcher;
962 statfs_result = statfs (local->filename, &statfs_buffer);
963 #elif STATFS_ARGS == 4
964 statfs_result = statfs (local->filename, &statfs_buffer,
965 sizeof (statfs_buffer), 0);
967 block_size = statfs_buffer.f_bsize;
969 /* Many backends can't report free size (for instance the gvfs fuse
970 backend for backend not supporting this), and set f_bfree to 0,
971 but it can be 0 for real too. We treat the availible == 0 and
972 free == 0 case as "both of these are invalid".
975 if (statfs_buffer.f_bavail == 0 && statfs_buffer.f_bfree == 0)
979 #elif defined(USE_STATVFS)
980 statfs_result = statvfs (local->filename, &statfs_buffer);
981 block_size = statfs_buffer.f_frsize;
984 if (statfs_result == -1)
988 g_set_error (error, G_IO_ERROR,
989 g_io_error_from_errno (errsv),
990 _("Error getting filesystem info: %s"),
995 info = g_file_info_new ();
997 attribute_matcher = g_file_attribute_matcher_new (attributes);
1000 g_file_attribute_matcher_matches (attribute_matcher,
1001 G_FILE_ATTRIBUTE_FILESYSTEM_FREE))
1004 gchar *localdir = g_path_get_dirname (local->filename);
1005 wchar_t *wdirname = g_utf8_to_utf16 (localdir, -1, NULL, NULL, NULL);
1009 if (GetDiskFreeSpaceExW (wdirname, &li, NULL, NULL))
1010 g_file_info_set_attribute_uint64 (info, G_FILE_ATTRIBUTE_FILESYSTEM_FREE, (guint64)li.QuadPart);
1013 g_file_info_set_attribute_uint64 (info, G_FILE_ATTRIBUTE_FILESYSTEM_FREE, block_size * statfs_buffer.f_bavail);
1017 g_file_attribute_matcher_matches (attribute_matcher,
1018 G_FILE_ATTRIBUTE_FILESYSTEM_SIZE))
1021 gchar *localdir = g_path_get_dirname (local->filename);
1022 wchar_t *wdirname = g_utf8_to_utf16 (localdir, -1, NULL, NULL, NULL);
1026 if (GetDiskFreeSpaceExW (wdirname, NULL, &li, NULL))
1027 g_file_info_set_attribute_uint64 (info, G_FILE_ATTRIBUTE_FILESYSTEM_SIZE, (guint64)li.QuadPart);
1030 g_file_info_set_attribute_uint64 (info, G_FILE_ATTRIBUTE_FILESYSTEM_SIZE, block_size * statfs_buffer.f_blocks);
1034 #if defined(HAVE_STRUCT_STATFS_F_FSTYPENAME)
1035 fstype = g_strdup(statfs_buffer.f_fstypename);
1037 fstype = get_fs_type (statfs_buffer.f_type);
1040 #elif defined(USE_STATVFS) && defined(HAVE_STRUCT_STATVFS_F_BASETYPE)
1041 fstype = g_strdup(statfs_buffer.f_basetype);
1046 g_file_attribute_matcher_matches (attribute_matcher,
1047 G_FILE_ATTRIBUTE_FILESYSTEM_TYPE))
1048 g_file_info_set_attribute_string (info, G_FILE_ATTRIBUTE_FILESYSTEM_TYPE, fstype);
1051 if (g_file_attribute_matcher_matches (attribute_matcher,
1052 G_FILE_ATTRIBUTE_FILESYSTEM_READONLY))
1055 get_filesystem_readonly (info, local->filename);
1057 get_mount_info (info, local->filename, attribute_matcher);
1061 g_file_attribute_matcher_unref (attribute_matcher);
1067 g_local_file_find_enclosing_mount (GFile *file,
1068 GCancellable *cancellable,
1071 GLocalFile *local = G_LOCAL_FILE (file);
1076 if (g_lstat (local->filename, &buf) != 0)
1078 g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
1079 /* Translators: This is an error message when trying to
1080 * find the enclosing (user visible) mount of a file, but
1082 _("Containing mount does not exist"));
1086 mountpoint = find_mountpoint_for (local->filename, buf.st_dev);
1087 if (mountpoint == NULL)
1089 g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
1090 /* Translators: This is an error message when trying to
1091 * find the enclosing (user visible) mount of a file, but
1093 _("Containing mount does not exist"));
1097 mount = _g_mount_get_for_mount_path (mountpoint, cancellable);
1098 g_free (mountpoint);
1102 g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
1103 /* Translators: This is an error message when trying to find
1104 * the enclosing (user visible) mount of a file, but none
1106 _("Containing mount does not exist"));
1111 g_local_file_set_display_name (GFile *file,
1112 const char *display_name,
1113 GCancellable *cancellable,
1116 GLocalFile *local, *new_local;
1117 GFile *new_file, *parent;
1118 struct stat statbuf;
1121 parent = g_file_get_parent (file);
1124 g_set_error_literal (error, G_IO_ERROR,
1126 _("Can't rename root directory"));
1130 new_file = g_file_get_child_for_display_name (parent, display_name, error);
1131 g_object_unref (parent);
1133 if (new_file == NULL)
1135 local = G_LOCAL_FILE (file);
1136 new_local = G_LOCAL_FILE (new_file);
1138 if (g_lstat (new_local->filename, &statbuf) == -1)
1142 if (errsv != ENOENT)
1144 g_set_error (error, G_IO_ERROR,
1145 g_io_error_from_errno (errsv),
1146 _("Error renaming file: %s"),
1147 g_strerror (errsv));
1153 g_set_error_literal (error, G_IO_ERROR,
1155 _("Can't rename file, filename already exist"));
1159 if (g_rename (local->filename, new_local->filename) == -1)
1163 if (errsv == EINVAL)
1164 /* We can't get a rename file into itself error herer,
1165 so this must be an invalid filename, on e.g. FAT */
1166 g_set_error_literal (error, G_IO_ERROR,
1167 G_IO_ERROR_INVALID_FILENAME,
1168 _("Invalid filename"));
1170 g_set_error (error, G_IO_ERROR,
1171 g_io_error_from_errno (errsv),
1172 _("Error renaming file: %s"),
1173 g_strerror (errsv));
1174 g_object_unref (new_file);
1182 g_local_file_query_info (GFile *file,
1183 const char *attributes,
1184 GFileQueryInfoFlags flags,
1185 GCancellable *cancellable,
1188 GLocalFile *local = G_LOCAL_FILE (file);
1190 GFileAttributeMatcher *matcher;
1191 char *basename, *dirname;
1192 GLocalParentFileInfo parent_info;
1194 matcher = g_file_attribute_matcher_new (attributes);
1196 basename = g_path_get_basename (local->filename);
1198 dirname = g_path_get_dirname (local->filename);
1199 _g_local_file_info_get_parent_info (dirname, matcher, &parent_info);
1202 info = _g_local_file_info_get (basename, local->filename,
1203 matcher, flags, &parent_info,
1208 g_file_attribute_matcher_unref (matcher);
1213 static GFileAttributeInfoList *
1214 g_local_file_query_settable_attributes (GFile *file,
1215 GCancellable *cancellable,
1218 return g_file_attribute_info_list_ref (local_writable_attributes);
1221 static GFileAttributeInfoList *
1222 g_local_file_query_writable_namespaces (GFile *file,
1223 GCancellable *cancellable,
1226 return g_file_attribute_info_list_ref (local_writable_namespaces);
1230 g_local_file_set_attribute (GFile *file,
1231 const char *attribute,
1232 GFileAttributeType type,
1234 GFileQueryInfoFlags flags,
1235 GCancellable *cancellable,
1238 GLocalFile *local = G_LOCAL_FILE (file);
1240 return _g_local_file_info_set_attribute (local->filename,
1250 g_local_file_set_attributes_from_info (GFile *file,
1252 GFileQueryInfoFlags flags,
1253 GCancellable *cancellable,
1256 GLocalFile *local = G_LOCAL_FILE (file);
1257 int res, chained_res;
1258 GFileIface *default_iface;
1260 res = _g_local_file_info_set_attributes (local->filename,
1266 error = NULL; /* Don't write over error if further errors */
1268 default_iface = g_type_default_interface_peek (G_TYPE_FILE);
1270 chained_res = (default_iface->set_attributes_from_info) (file, info, flags, cancellable, error);
1272 return res && chained_res;
1275 static GFileInputStream *
1276 g_local_file_read (GFile *file,
1277 GCancellable *cancellable,
1280 GLocalFile *local = G_LOCAL_FILE (file);
1284 fd = g_open (local->filename, O_RDONLY|O_BINARY, 0);
1289 g_set_error (error, G_IO_ERROR,
1290 g_io_error_from_errno (errsv),
1291 _("Error opening file: %s"),
1292 g_strerror (errsv));
1296 if (fstat(fd, &buf) == 0 && S_ISDIR (buf.st_mode))
1299 g_set_error_literal (error, G_IO_ERROR,
1300 G_IO_ERROR_IS_DIRECTORY,
1301 _("Can't open directory"));
1305 return _g_local_file_input_stream_new (fd);
1308 static GFileOutputStream *
1309 g_local_file_append_to (GFile *file,
1310 GFileCreateFlags flags,
1311 GCancellable *cancellable,
1314 return _g_local_file_output_stream_append (G_LOCAL_FILE (file)->filename,
1315 flags, cancellable, error);
1318 static GFileOutputStream *
1319 g_local_file_create (GFile *file,
1320 GFileCreateFlags flags,
1321 GCancellable *cancellable,
1324 return _g_local_file_output_stream_create (G_LOCAL_FILE (file)->filename,
1325 flags, cancellable, error);
1328 static GFileOutputStream *
1329 g_local_file_replace (GFile *file,
1331 gboolean make_backup,
1332 GFileCreateFlags flags,
1333 GCancellable *cancellable,
1336 return _g_local_file_output_stream_replace (G_LOCAL_FILE (file)->filename,
1337 etag, make_backup, flags,
1338 cancellable, error);
1343 g_local_file_delete (GFile *file,
1344 GCancellable *cancellable,
1347 GLocalFile *local = G_LOCAL_FILE (file);
1349 if (g_remove (local->filename) == -1)
1353 /* Posix allows EEXIST too, but the more sane error
1354 is G_IO_ERROR_NOT_FOUND, and it's what nautilus
1356 if (errsv == EEXIST)
1359 g_set_error (error, G_IO_ERROR,
1360 g_io_error_from_errno (errsv),
1361 _("Error removing file: %s"),
1362 g_strerror (errsv));
1370 strip_trailing_slashes (const char *path)
1375 path_copy = g_strdup (path);
1376 len = strlen (path_copy);
1377 while (len > 1 && path_copy[len-1] == '/')
1378 path_copy[--len] = 0;
1384 expand_symlink (const char *link)
1386 char *resolved, *canonical, *parent, *link2;
1387 char symlink_value[4096];
1395 res = readlink (link, symlink_value, sizeof (symlink_value) - 1);
1398 return g_strdup (link);
1399 symlink_value[res] = 0;
1402 if (g_path_is_absolute (symlink_value))
1403 return canonicalize_filename (symlink_value);
1406 link2 = strip_trailing_slashes (link);
1407 parent = g_path_get_dirname (link2);
1410 resolved = g_build_filename (parent, symlink_value, NULL);
1413 canonical = canonicalize_filename (resolved);
1422 get_parent (const char *path,
1426 struct stat parent_stat;
1430 path_copy = strip_trailing_slashes (path);
1432 parent = g_path_get_dirname (path_copy);
1433 if (strcmp (parent, ".") == 0 ||
1434 strcmp (parent, path_copy) == 0)
1444 if (g_lstat (parent, &parent_stat) != 0)
1450 if (S_ISLNK (parent_stat.st_mode))
1453 parent = expand_symlink (parent);
1458 if (num_recursions > 12)
1463 } while (S_ISLNK (parent_stat.st_mode));
1465 *parent_dev = parent_stat.st_dev;
1471 expand_all_symlinks (const char *path)
1473 char *parent, *parent_expanded;
1474 char *basename, *res;
1477 parent = get_parent (path, &parent_dev);
1480 parent_expanded = expand_all_symlinks (parent);
1482 basename = g_path_get_basename (path);
1483 res = g_build_filename (parent_expanded, basename, NULL);
1485 g_free (parent_expanded);
1488 res = g_strdup (path);
1496 find_mountpoint_for (const char *file,
1500 dev_t dir_dev, parent_dev;
1502 dir = g_strdup (file);
1507 parent = get_parent (dir, &parent_dev);
1511 if (parent_dev != dir_dev)
1523 find_topdir_for (const char *file)
1528 dir = get_parent (file, &dir_dev);
1532 return find_mountpoint_for (dir, dir_dev);
1536 get_unique_filename (const char *basename,
1542 return g_strdup (basename);
1544 dot = strchr (basename, '.');
1546 return g_strdup_printf ("%.*s.%d%s", (int)(dot - basename), basename, id, dot);
1548 return g_strdup_printf ("%s.%d", basename, id);
1552 path_has_prefix (const char *path,
1560 prefix_len = strlen (prefix);
1562 if (strncmp (path, prefix, prefix_len) == 0 &&
1563 (prefix_len == 0 || /* empty prefix always matches */
1564 prefix[prefix_len - 1] == '/' || /* last char in prefix was a /, so it must be in path too */
1565 path[prefix_len] == 0 ||
1566 path[prefix_len] == '/'))
1573 try_make_relative (const char *path,
1576 char *path2, *base2;
1579 path2 = expand_all_symlinks (path);
1580 base2 = expand_all_symlinks (base);
1583 if (path_has_prefix (path2, base2))
1585 relative = path2 + strlen (base2);
1586 while (*relative == '/')
1588 relative = g_strdup (relative);
1596 /* Failed, use abs path */
1597 return g_strdup (path);
1601 escape_trash_name (char *name)
1604 const gchar hex[16] = "0123456789ABCDEF";
1606 str = g_string_new ("");
1614 if (g_ascii_isprint (c))
1615 g_string_append_c (str, c);
1618 g_string_append_c (str, '%');
1619 g_string_append_c (str, hex[((guchar)c) >> 4]);
1620 g_string_append_c (str, hex[((guchar)c) & 0xf]);
1624 return g_string_free (str, FALSE);
1628 _g_local_file_has_trash_dir (const char *dirname, dev_t dir_dev)
1630 static gsize home_dev_set = 0;
1631 static dev_t home_dev;
1632 char *topdir, *globaldir, *trashdir, *tmpname;
1635 struct stat global_stat, trash_stat;
1639 if (g_once_init_enter (&home_dev_set))
1641 struct stat home_stat;
1643 g_stat (g_get_home_dir (), &home_stat);
1644 home_dev = home_stat.st_dev;
1645 g_once_init_leave (&home_dev_set, 1);
1648 /* Assume we can trash to the home */
1649 if (dir_dev == home_dev)
1652 topdir = find_mountpoint_for (dirname, dir_dev);
1656 globaldir = g_build_filename (topdir, ".Trash", NULL);
1657 statres = g_lstat (globaldir, &global_stat);
1658 if (g_lstat (globaldir, &global_stat) == 0 &&
1659 S_ISDIR (global_stat.st_mode) &&
1660 (global_stat.st_mode & S_ISVTX) != 0)
1662 /* got a toplevel sysadmin created dir, assume we
1663 * can trash to it (we should be able to create a dir)
1664 * This fails for the FAT case where the ownership of
1665 * that dir would be wrong though..
1673 /* No global trash dir, or it failed the tests, fall back to $topdir/.Trash-$uid */
1675 g_snprintf (uid_str, sizeof (uid_str), "%lu", (unsigned long) uid);
1677 tmpname = g_strdup_printf (".Trash-%s", uid_str);
1678 trashdir = g_build_filename (topdir, tmpname, NULL);
1681 if (g_lstat (trashdir, &trash_stat) == 0)
1686 S_ISDIR (trash_stat.st_mode) &&
1687 trash_stat.st_uid == uid;
1691 /* User specific trash didn't exist, can we create it? */
1692 res = g_access (topdir, W_OK) == 0;
1701 g_local_file_trash (GFile *file,
1702 GCancellable *cancellable,
1705 GLocalFile *local = G_LOCAL_FILE (file);
1706 struct stat file_stat, home_stat;
1707 const char *homedir;
1708 char *trashdir, *topdir, *infodir, *filesdir;
1709 char *basename, *trashname, *trashfile, *infoname, *infofile;
1710 char *original_name, *original_name_escaped;
1713 gboolean is_homedir_trash;
1714 char delete_time[32];
1716 struct stat trash_stat, global_stat;
1717 char *dirname, *globaldir;
1719 if (g_lstat (local->filename, &file_stat) != 0)
1723 g_set_error (error, G_IO_ERROR,
1724 g_io_error_from_errno (errsv),
1725 _("Error trashing file: %s"),
1726 g_strerror (errsv));
1730 homedir = g_get_home_dir ();
1731 g_stat (homedir, &home_stat);
1733 is_homedir_trash = FALSE;
1735 if (file_stat.st_dev == home_stat.st_dev)
1737 is_homedir_trash = TRUE;
1739 trashdir = g_build_filename (g_get_user_data_dir (), "Trash", NULL);
1740 if (g_mkdir_with_parents (trashdir, 0700) < 0)
1745 display_name = g_filename_display_name (trashdir);
1746 g_set_error (error, G_IO_ERROR,
1747 g_io_error_from_errno (errsv),
1748 _("Unable to create trash dir %s: %s"),
1749 display_name, g_strerror (errsv));
1750 g_free (display_name);
1754 topdir = g_strdup (g_get_user_data_dir ());
1762 g_snprintf (uid_str, sizeof (uid_str), "%lu", (unsigned long)uid);
1764 topdir = find_topdir_for (local->filename);
1767 g_set_error_literal (error, G_IO_ERROR,
1768 G_IO_ERROR_NOT_SUPPORTED,
1769 _("Unable to find toplevel directory for trash"));
1773 /* Try looking for global trash dir $topdir/.Trash/$uid */
1774 globaldir = g_build_filename (topdir, ".Trash", NULL);
1775 if (g_lstat (globaldir, &global_stat) == 0 &&
1776 S_ISDIR (global_stat.st_mode) &&
1777 (global_stat.st_mode & S_ISVTX) != 0)
1779 trashdir = g_build_filename (globaldir, uid_str, NULL);
1781 if (g_lstat (trashdir, &trash_stat) == 0)
1783 if (!S_ISDIR (trash_stat.st_mode) ||
1784 trash_stat.st_uid != uid)
1786 /* Not a directory or not owned by user, ignore */
1791 else if (g_mkdir (trashdir, 0700) == -1)
1799 if (trashdir == NULL)
1801 gboolean tried_create;
1803 /* No global trash dir, or it failed the tests, fall back to $topdir/.Trash-$uid */
1804 dirname = g_strdup_printf (".Trash-%s", uid_str);
1805 trashdir = g_build_filename (topdir, dirname, NULL);
1808 tried_create = FALSE;
1811 if (g_lstat (trashdir, &trash_stat) == 0)
1813 if (!S_ISDIR (trash_stat.st_mode) ||
1814 trash_stat.st_uid != uid)
1816 /* Remove the failed directory */
1818 g_remove (trashdir);
1820 /* Not a directory or not owned by user, ignore */
1827 if (!tried_create &&
1828 g_mkdir (trashdir, 0700) != -1)
1830 /* Ensure that the created dir has the right uid etc.
1831 This might fail on e.g. a FAT dir */
1832 tried_create = TRUE;
1843 if (trashdir == NULL)
1846 g_set_error_literal (error, G_IO_ERROR,
1847 G_IO_ERROR_NOT_SUPPORTED,
1848 _("Unable to find or create trash directory"));
1853 /* Trashdir points to the trash dir with the "info" and "files" subdirectories */
1855 infodir = g_build_filename (trashdir, "info", NULL);
1856 filesdir = g_build_filename (trashdir, "files", NULL);
1859 /* Make sure we have the subdirectories */
1860 if ((g_mkdir (infodir, 0700) == -1 && errno != EEXIST) ||
1861 (g_mkdir (filesdir, 0700) == -1 && errno != EEXIST))
1866 g_set_error_literal (error, G_IO_ERROR,
1867 G_IO_ERROR_NOT_SUPPORTED,
1868 _("Unable to find or create trash directory"));
1872 basename = g_path_get_basename (local->filename);
1880 trashname = get_unique_filename (basename, i++);
1881 infoname = g_strconcat (trashname, ".trashinfo", NULL);
1882 infofile = g_build_filename (infodir, infoname, NULL);
1885 fd = open (infofile, O_CREAT | O_EXCL, 0666);
1886 } while (fd == -1 && errno == EEXIST);
1900 g_set_error (error, G_IO_ERROR,
1901 g_io_error_from_errno (errsv),
1902 _("Unable to create trashing info file: %s"),
1903 g_strerror (errsv));
1909 /* TODO: Maybe we should verify that you can delete the file from the trash
1910 before moving it? OTOH, that is hard, as it needs a recursive scan */
1912 trashfile = g_build_filename (filesdir, trashname, NULL);
1916 if (g_rename (local->filename, trashfile) == -1)
1925 g_set_error (error, G_IO_ERROR,
1926 g_io_error_from_errno (errsv),
1927 _("Unable to trash file: %s"),
1928 g_strerror (errsv));
1934 /* TODO: Do we need to update mtime/atime here after the move? */
1936 /* Use absolute names for homedir */
1937 if (is_homedir_trash)
1938 original_name = g_strdup (local->filename);
1940 original_name = try_make_relative (local->filename, topdir);
1941 original_name_escaped = escape_trash_name (original_name);
1943 g_free (original_name);
1950 localtime_r (&t, &now);
1952 strftime(delete_time, sizeof (delete_time), "%Y-%m-%dT%H:%M:%S", &now);
1955 data = g_strdup_printf ("[Trash Info]\nPath=%s\nDeletionDate=%s\n",
1956 original_name_escaped, delete_time);
1958 g_file_set_contents (infofile, data, -1, NULL);
1962 g_free (original_name_escaped);
1967 #else /* G_OS_WIN32 */
1969 _g_local_file_has_trash_dir (const char *dirname, dev_t dir_dev)
1971 return FALSE; /* XXX ??? */
1975 g_local_file_trash (GFile *file,
1976 GCancellable *cancellable,
1979 GLocalFile *local = G_LOCAL_FILE (file);
1980 SHFILEOPSTRUCTW op = {0};
1985 wfilename = g_utf8_to_utf16 (local->filename, -1, NULL, &len, NULL);
1986 /* SHFILEOPSTRUCT.pFrom is double-zero-terminated */
1987 wfilename = g_renew (wchar_t, wfilename, len + 2);
1988 wfilename[len + 1] = 0;
1990 op.wFunc = FO_DELETE;
1991 op.pFrom = wfilename;
1992 op.fFlags = FOF_ALLOWUNDO;
1994 success = SHFileOperationW (&op) == 0;
1996 if (success && op.fAnyOperationsAborted)
1998 if (cancellable && !g_cancellable_is_cancelled (cancellable))
1999 g_cancellable_cancel (cancellable);
2000 g_set_error (error, G_IO_ERROR,
2001 G_IO_ERROR_CANCELLED,
2002 _("Unable to trash file: %s"),
2003 _("Operation was cancelled"));
2007 g_set_error (error, G_IO_ERROR,
2009 _("Unable to trash file: %s"),
2010 _("internal error"));
2015 #endif /* G_OS_WIN32 */
2018 g_local_file_make_directory (GFile *file,
2019 GCancellable *cancellable,
2022 GLocalFile *local = G_LOCAL_FILE (file);
2024 if (g_mkdir (local->filename, 0777) == -1)
2028 if (errsv == EINVAL)
2029 /* This must be an invalid filename, on e.g. FAT */
2030 g_set_error_literal (error, G_IO_ERROR,
2031 G_IO_ERROR_INVALID_FILENAME,
2032 _("Invalid filename"));
2034 g_set_error (error, G_IO_ERROR,
2035 g_io_error_from_errno (errsv),
2036 _("Error creating directory: %s"),
2037 g_strerror (errsv));
2045 g_local_file_make_symbolic_link (GFile *file,
2046 const char *symlink_value,
2047 GCancellable *cancellable,
2051 GLocalFile *local = G_LOCAL_FILE (file);
2053 if (symlink (symlink_value, local->filename) == -1)
2057 if (errsv == EINVAL)
2058 /* This must be an invalid filename, on e.g. FAT */
2059 g_set_error_literal (error, G_IO_ERROR,
2060 G_IO_ERROR_INVALID_FILENAME,
2061 _("Invalid filename"));
2063 g_set_error (error, G_IO_ERROR,
2064 g_io_error_from_errno (errsv),
2065 _("Error making symbolic link: %s"),
2066 g_strerror (errsv));
2071 g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, "Symlinks not supported");
2078 g_local_file_copy (GFile *source,
2080 GFileCopyFlags flags,
2081 GCancellable *cancellable,
2082 GFileProgressCallback progress_callback,
2083 gpointer progress_callback_data,
2086 /* Fall back to default copy */
2087 g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, "Copy not supported");
2092 g_local_file_move (GFile *source,
2094 GFileCopyFlags flags,
2095 GCancellable *cancellable,
2096 GFileProgressCallback progress_callback,
2097 gpointer progress_callback_data,
2100 GLocalFile *local_source, *local_destination;
2101 struct stat statbuf;
2102 gboolean destination_exist, source_is_dir;
2107 if (!G_IS_LOCAL_FILE (source) ||
2108 !G_IS_LOCAL_FILE (destination))
2110 /* Fall back to default move */
2111 g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, "Move not supported");
2115 local_source = G_LOCAL_FILE (source);
2116 local_destination = G_LOCAL_FILE (destination);
2118 res = g_lstat (local_source->filename, &statbuf);
2123 g_set_error (error, G_IO_ERROR,
2124 g_io_error_from_errno (errsv),
2125 _("Error moving file: %s"),
2126 g_strerror (errsv));
2130 source_is_dir = S_ISDIR (statbuf.st_mode);
2131 source_size = statbuf.st_size;
2133 destination_exist = FALSE;
2134 res = g_lstat (local_destination->filename, &statbuf);
2137 destination_exist = TRUE; /* Target file exists */
2139 if (flags & G_FILE_COPY_OVERWRITE)
2141 /* Always fail on dirs, even with overwrite */
2142 if (S_ISDIR (statbuf.st_mode))
2145 g_set_error_literal (error,
2147 G_IO_ERROR_WOULD_MERGE,
2148 _("Can't move directory over directory"));
2150 g_set_error_literal (error,
2152 G_IO_ERROR_IS_DIRECTORY,
2153 _("Can't copy over directory"));
2159 g_set_error_literal (error,
2162 _("Target file exists"));
2167 if (flags & G_FILE_COPY_BACKUP && destination_exist)
2169 backup_name = g_strconcat (local_destination->filename, "~", NULL);
2170 if (g_rename (local_destination->filename, backup_name) == -1)
2172 g_set_error_literal (error,
2174 G_IO_ERROR_CANT_CREATE_BACKUP,
2175 _("Backup file creation failed"));
2176 g_free (backup_name);
2179 g_free (backup_name);
2180 destination_exist = FALSE; /* It did, but no more */
2183 if (source_is_dir && destination_exist && (flags & G_FILE_COPY_OVERWRITE))
2185 /* Source is a dir, destination exists (and is not a dir, because that would have failed
2186 earlier), and we're overwriting. Manually remove the target so we can do the rename. */
2187 res = g_unlink (local_destination->filename);
2192 g_set_error (error, G_IO_ERROR,
2193 g_io_error_from_errno (errsv),
2194 _("Error removing target file: %s"),
2195 g_strerror (errsv));
2200 if (g_rename (local_source->filename, local_destination->filename) == -1)
2205 /* This will cause the fallback code to run */
2206 g_set_error_literal (error, G_IO_ERROR,
2207 G_IO_ERROR_NOT_SUPPORTED,
2208 _("Move between mounts not supported"));
2209 else if (errsv == EINVAL)
2210 /* This must be an invalid filename, on e.g. FAT, or
2211 we're trying to move the file into itself...
2212 We return invalid filename for both... */
2213 g_set_error_literal (error, G_IO_ERROR,
2214 G_IO_ERROR_INVALID_FILENAME,
2215 _("Invalid filename"));
2217 g_set_error (error, G_IO_ERROR,
2218 g_io_error_from_errno (errsv),
2219 _("Error moving file: %s"),
2220 g_strerror (errsv));
2224 /* Make sure we send full copied size */
2225 if (progress_callback)
2226 progress_callback (source_size, source_size, progress_callback_data);
2231 static GFileMonitor*
2232 g_local_file_monitor_dir (GFile *file,
2233 GFileMonitorFlags flags,
2234 GCancellable *cancellable,
2237 GLocalFile* local_file = G_LOCAL_FILE(file);
2238 return _g_local_directory_monitor_new (local_file->filename, flags, error);
2241 static GFileMonitor*
2242 g_local_file_monitor_file (GFile *file,
2243 GFileMonitorFlags flags,
2244 GCancellable *cancellable,
2247 GLocalFile* local_file = G_LOCAL_FILE(file);
2248 return _g_local_file_monitor_new (local_file->filename, flags, error);
2252 g_local_file_file_iface_init (GFileIface *iface)
2254 iface->dup = g_local_file_dup;
2255 iface->hash = g_local_file_hash;
2256 iface->equal = g_local_file_equal;
2257 iface->is_native = g_local_file_is_native;
2258 iface->has_uri_scheme = g_local_file_has_uri_scheme;
2259 iface->get_uri_scheme = g_local_file_get_uri_scheme;
2260 iface->get_basename = g_local_file_get_basename;
2261 iface->get_path = g_local_file_get_path;
2262 iface->get_uri = g_local_file_get_uri;
2263 iface->get_parse_name = g_local_file_get_parse_name;
2264 iface->get_parent = g_local_file_get_parent;
2265 iface->prefix_matches = g_local_file_prefix_matches;
2266 iface->get_relative_path = g_local_file_get_relative_path;
2267 iface->resolve_relative_path = g_local_file_resolve_relative_path;
2268 iface->get_child_for_display_name = g_local_file_get_child_for_display_name;
2269 iface->set_display_name = g_local_file_set_display_name;
2270 iface->enumerate_children = g_local_file_enumerate_children;
2271 iface->query_info = g_local_file_query_info;
2272 iface->query_filesystem_info = g_local_file_query_filesystem_info;
2273 iface->find_enclosing_mount = g_local_file_find_enclosing_mount;
2274 iface->query_settable_attributes = g_local_file_query_settable_attributes;
2275 iface->query_writable_namespaces = g_local_file_query_writable_namespaces;
2276 iface->set_attribute = g_local_file_set_attribute;
2277 iface->set_attributes_from_info = g_local_file_set_attributes_from_info;
2278 iface->read_fn = g_local_file_read;
2279 iface->append_to = g_local_file_append_to;
2280 iface->create = g_local_file_create;
2281 iface->replace = g_local_file_replace;
2282 iface->delete_file = g_local_file_delete;
2283 iface->trash = g_local_file_trash;
2284 iface->make_directory = g_local_file_make_directory;
2285 iface->make_symbolic_link = g_local_file_make_symbolic_link;
2286 iface->copy = g_local_file_copy;
2287 iface->move = g_local_file_move;
2288 iface->monitor_dir = g_local_file_monitor_dir;
2289 iface->monitor_file = g_local_file_monitor_file;