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_WHEN_MOVED);
183 g_file_attribute_info_list_add (list,
184 G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC,
185 G_FILE_ATTRIBUTE_TYPE_UINT32,
186 G_FILE_ATTRIBUTE_INFO_COPY_WHEN_MOVED);
187 g_file_attribute_info_list_add (list,
188 G_FILE_ATTRIBUTE_TIME_ACCESS,
189 G_FILE_ATTRIBUTE_TYPE_UINT64,
190 G_FILE_ATTRIBUTE_INFO_COPY_WHEN_MOVED);
191 g_file_attribute_info_list_add (list,
192 G_FILE_ATTRIBUTE_TIME_ACCESS_USEC,
193 G_FILE_ATTRIBUTE_TYPE_UINT32,
194 G_FILE_ATTRIBUTE_INFO_COPY_WHEN_MOVED);
197 local_writable_attributes = list;
199 /* Writable namespaces: */
201 list = g_file_attribute_info_list_new ();
204 g_file_attribute_info_list_add (list,
206 G_FILE_ATTRIBUTE_TYPE_STRING,
207 G_FILE_ATTRIBUTE_INFO_COPY_WITH_FILE |
208 G_FILE_ATTRIBUTE_INFO_COPY_WHEN_MOVED);
209 g_file_attribute_info_list_add (list,
211 G_FILE_ATTRIBUTE_TYPE_STRING,
212 G_FILE_ATTRIBUTE_INFO_COPY_WHEN_MOVED);
215 local_writable_namespaces = list;
219 g_local_file_init (GLocalFile *local)
225 canonicalize_filename (const char *filename)
227 char *canon, *start, *p, *q;
231 if (!g_path_is_absolute (filename))
233 cwd = g_get_current_dir ();
234 canon = g_build_filename (cwd, filename, NULL);
238 canon = g_strdup (filename);
240 start = (char *)g_path_skip_root (canon);
242 /* POSIX allows double slashes at the start to
243 * mean something special (as does windows too).
244 * So, "//" != "/", but more than two slashes
250 G_IS_DIR_SEPARATOR (*p);
257 memmove (start, start+i, strlen (start+i)+1);
263 if (p[0] == '.' && (p[1] == 0 || G_IS_DIR_SEPARATOR (p[1])))
265 memmove (p, p+1, strlen (p+1)+1);
267 else if (p[0] == '.' && p[1] == '.' && (p[2] == 0 || G_IS_DIR_SEPARATOR (p[2])))
270 /* Skip previous separator */
274 while (p > start && !G_IS_DIR_SEPARATOR (*p))
276 if (G_IS_DIR_SEPARATOR (*p))
277 *p++ = G_DIR_SEPARATOR;
278 memmove (p, q, strlen (q)+1);
282 /* Skip until next separator */
283 while (*p != 0 && !G_IS_DIR_SEPARATOR (*p))
288 /* Canonicalize one separator */
289 *p++ = G_DIR_SEPARATOR;
293 /* Remove additional separators */
295 while (*q && G_IS_DIR_SEPARATOR (*q))
299 memmove (p, q, strlen (q)+1);
302 /* Remove trailing slashes */
303 if (p > start && G_IS_DIR_SEPARATOR (*(p-1)))
311 * @filename: filename of the file to create.
313 * Returns: new local #GFile.
316 _g_local_file_new (const char *filename)
320 local = g_object_new (G_TYPE_LOCAL_FILE, NULL);
321 local->filename = canonicalize_filename (filename);
323 return G_FILE (local);
327 g_local_file_is_native (GFile *file)
333 g_local_file_has_uri_scheme (GFile *file,
334 const char *uri_scheme)
336 return g_ascii_strcasecmp (uri_scheme, "file") == 0;
340 g_local_file_get_uri_scheme (GFile *file)
342 return g_strdup ("file");
346 g_local_file_get_basename (GFile *file)
348 return g_path_get_basename (G_LOCAL_FILE (file)->filename);
352 g_local_file_get_path (GFile *file)
354 return g_strdup (G_LOCAL_FILE (file)->filename);
358 g_local_file_get_uri (GFile *file)
360 return g_filename_to_uri (G_LOCAL_FILE (file)->filename, NULL, NULL);
364 get_filename_charset (const gchar **filename_charset)
366 const gchar **charsets;
369 is_utf8 = g_get_filename_charsets (&charsets);
371 if (filename_charset)
372 *filename_charset = charsets[0];
378 name_is_valid_for_display (const char *string,
379 gboolean is_valid_utf8)
383 if (!is_valid_utf8 &&
384 !g_utf8_validate (string, -1, NULL))
387 while ((c = *string++) != 0)
389 if (g_ascii_iscntrl (c))
397 g_local_file_get_parse_name (GFile *file)
399 const char *filename;
401 const gchar *charset;
403 char *roundtripped_filename;
404 gboolean free_utf8_filename;
405 gboolean is_valid_utf8;
408 filename = G_LOCAL_FILE (file)->filename;
409 if (get_filename_charset (&charset))
411 utf8_filename = (char *)filename;
412 free_utf8_filename = FALSE;
413 is_valid_utf8 = FALSE; /* Can't guarantee this */
417 utf8_filename = g_convert (filename, -1,
418 "UTF-8", charset, NULL, NULL, NULL);
419 free_utf8_filename = TRUE;
420 is_valid_utf8 = TRUE;
422 if (utf8_filename != NULL)
424 /* Make sure we can roundtrip: */
425 roundtripped_filename = g_convert (utf8_filename, -1,
426 charset, "UTF-8", NULL, NULL, NULL);
428 if (roundtripped_filename == NULL ||
429 strcmp (utf8_filename, roundtripped_filename) != 0)
431 g_free (utf8_filename);
432 utf8_filename = NULL;
435 g_free (roundtripped_filename);
439 if (utf8_filename != NULL &&
440 name_is_valid_for_display (utf8_filename, is_valid_utf8))
442 if (free_utf8_filename)
443 parse_name = utf8_filename;
445 parse_name = g_strdup (utf8_filename);
449 escaped_path = g_uri_escape_string (filename,
450 G_URI_RESERVED_CHARS_ALLOWED_IN_PATH_ELEMENT "/",
452 parse_name = g_strconcat ("file://",
453 (*escaped_path != '/') ? "/" : "",
457 g_free (escaped_path);
459 if (free_utf8_filename)
460 g_free (utf8_filename);
467 g_local_file_get_parent (GFile *file)
469 GLocalFile *local = G_LOCAL_FILE (file);
470 const char *non_root;
475 non_root = g_path_skip_root (local->filename);
479 dirname = g_path_get_dirname (local->filename);
480 parent = _g_local_file_new (dirname);
486 g_local_file_dup (GFile *file)
488 GLocalFile *local = G_LOCAL_FILE (file);
490 return _g_local_file_new (local->filename);
494 g_local_file_hash (GFile *file)
496 GLocalFile *local = G_LOCAL_FILE (file);
498 return g_str_hash (local->filename);
502 g_local_file_equal (GFile *file1,
505 GLocalFile *local1 = G_LOCAL_FILE (file1);
506 GLocalFile *local2 = G_LOCAL_FILE (file2);
508 return g_str_equal (local1->filename, local2->filename);
512 match_prefix (const char *path,
517 prefix_len = strlen (prefix);
518 if (strncmp (path, prefix, prefix_len) != 0)
521 /* Handle the case where prefix is the root, so that
522 * the IS_DIR_SEPRARATOR check below works */
523 if (prefix_len > 0 &&
524 G_IS_DIR_SEPARATOR (prefix[prefix_len-1]))
527 return path + prefix_len;
531 g_local_file_prefix_matches (GFile *parent,
534 GLocalFile *parent_local = G_LOCAL_FILE (parent);
535 GLocalFile *descendant_local = G_LOCAL_FILE (descendant);
536 const char *remainder;
538 remainder = match_prefix (descendant_local->filename, parent_local->filename);
539 if (remainder != NULL && G_IS_DIR_SEPARATOR (*remainder))
545 g_local_file_get_relative_path (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);
554 if (remainder != NULL && G_IS_DIR_SEPARATOR (*remainder))
555 return g_strdup (remainder + 1);
560 g_local_file_resolve_relative_path (GFile *file,
561 const char *relative_path)
563 GLocalFile *local = G_LOCAL_FILE (file);
567 if (g_path_is_absolute (relative_path))
568 return _g_local_file_new (relative_path);
570 filename = g_build_filename (local->filename, relative_path, NULL);
571 child = _g_local_file_new (filename);
577 static GFileEnumerator *
578 g_local_file_enumerate_children (GFile *file,
579 const char *attributes,
580 GFileQueryInfoFlags flags,
581 GCancellable *cancellable,
584 GLocalFile *local = G_LOCAL_FILE (file);
585 return _g_local_file_enumerator_new (local,
591 g_local_file_get_child_for_display_name (GFile *file,
592 const char *display_name,
598 basename = g_filename_from_utf8 (display_name, -1, NULL, NULL, NULL);
599 if (basename == NULL)
601 g_set_error (error, G_IO_ERROR,
602 G_IO_ERROR_INVALID_FILENAME,
603 _("Invalid filename %s"), display_name);
607 new_file = g_file_get_child (file, basename);
615 get_fs_type (long f_type)
618 /* filesystem ids taken from linux manpage */
719 G_LOCK_DEFINE_STATIC(mount_info_hash);
720 static GHashTable *mount_info_hash = NULL;
721 static guint64 mount_info_hash_cache_time = 0;
724 MOUNT_INFO_READONLY = 1<<0
728 device_equal (gconstpointer v1,
731 return *(dev_t *)v1 == *(dev_t *)v2;
735 device_hash (gconstpointer v)
737 return (guint) *(dev_t *)v;
741 get_mount_info (GFileInfo *fs_info,
743 GFileAttributeMatcher *matcher)
747 gpointer info_as_ptr;
751 GUnixMountEntry *mount;
754 if (g_lstat (path, &buf) != 0)
757 G_LOCK (mount_info_hash);
759 if (mount_info_hash == NULL)
760 mount_info_hash = g_hash_table_new_full (device_hash, device_equal,
764 if (g_unix_mounts_changed_since (mount_info_hash_cache_time))
765 g_hash_table_remove_all (mount_info_hash);
767 got_info = g_hash_table_lookup_extended (mount_info_hash,
772 G_UNLOCK (mount_info_hash);
774 mount_info = GPOINTER_TO_UINT (info_as_ptr);
780 mountpoint = find_mountpoint_for (path, buf.st_dev);
781 if (mountpoint == NULL)
782 mountpoint = g_strdup ("/");
784 mount = g_unix_mount_at (mountpoint, &cache_time);
787 if (g_unix_mount_is_readonly (mount))
788 mount_info |= MOUNT_INFO_READONLY;
790 g_unix_mount_free (mount);
795 dev = g_new0 (dev_t, 1);
798 G_LOCK (mount_info_hash);
799 mount_info_hash_cache_time = cache_time;
800 g_hash_table_insert (mount_info_hash, dev, GUINT_TO_POINTER (mount_info));
801 G_UNLOCK (mount_info_hash);
804 if (mount_info & MOUNT_INFO_READONLY)
805 g_file_info_set_attribute_boolean (fs_info, G_FILE_ATTRIBUTE_FILESYSTEM_READONLY, TRUE);
813 is_xp_or_later (void)
815 static int result = -1;
820 OSVERSIONINFOEX ver_info = {0};
821 DWORDLONG cond_mask = 0;
822 int op = VER_GREATER_EQUAL;
824 ver_info.dwOSVersionInfoSize = sizeof ver_info;
825 ver_info.dwMajorVersion = 5;
826 ver_info.dwMinorVersion = 1;
828 VER_SET_CONDITION (cond_mask, VER_MAJORVERSION, op);
829 VER_SET_CONDITION (cond_mask, VER_MINORVERSION, op);
831 result = VerifyVersionInfo (&ver_info,
832 VER_MAJORVERSION | VER_MINORVERSION,
835 result = ((DWORD)(LOBYTE (LOWORD (GetVersion ())))) >= 5;
843 get_volume_for_path (const char *path)
849 wpath = g_utf8_to_utf16 (path, -1, NULL, NULL, NULL);
850 result = g_new (wchar_t, MAX_PATH);
852 if (!GetVolumePathNameW (wpath, result, MAX_PATH))
854 char *msg = g_win32_error_message (GetLastError ());
855 g_critical ("GetVolumePathName failed: %s", msg);
862 len = wcslen (result);
863 if (len > 0 && result[len-1] != L'\\')
865 result = g_renew (wchar_t, result, len + 2);
875 find_mountpoint_for (const char *file, dev_t dev)
880 wpath = get_volume_for_path (file);
884 utf8_path = g_utf16_to_utf8 (wpath, -1, NULL, NULL, NULL);
891 get_filesystem_readonly (GFileInfo *info,
896 rootdir = get_volume_for_path (path);
900 if (is_xp_or_later ())
903 if (GetVolumeInformationW (rootdir, NULL, 0, NULL, NULL, &flags, NULL, 0))
904 g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_FILESYSTEM_READONLY,
905 (flags & FILE_READ_ONLY_VOLUME) != 0);
909 if (GetDriveTypeW (rootdir) == DRIVE_CDROM)
910 g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_FILESYSTEM_READONLY, TRUE);
917 #endif /* G_OS_WIN32 */
920 g_local_file_query_filesystem_info (GFile *file,
921 const char *attributes,
922 GCancellable *cancellable,
925 GLocalFile *local = G_LOCAL_FILE (file);
927 int statfs_result = 0;
933 struct statfs statfs_buffer;
934 #elif defined(USE_STATVFS)
935 struct statvfs statfs_buffer;
938 GFileAttributeMatcher *attribute_matcher;
945 statfs_result = statfs (local->filename, &statfs_buffer);
946 #elif STATFS_ARGS == 4
947 statfs_result = statfs (local->filename, &statfs_buffer,
948 sizeof (statfs_buffer), 0);
950 block_size = statfs_buffer.f_bsize;
952 #if defined(__linux__)
953 /* ncpfs does not know the amount of available and free space *
954 * assuming ncpfs is linux specific, if you are on a non-linux platform
955 * where ncpfs is available, please file a bug about it on bugzilla.gnome.org
957 if (statfs_buffer.f_bavail == 0 && statfs_buffer.f_bfree == 0 &&
958 /* linux/ncp_fs.h: NCP_SUPER_MAGIC == 0x564c */
959 statfs_buffer.f_type == 0x564c)
963 #elif defined(USE_STATVFS)
964 statfs_result = statvfs (local->filename, &statfs_buffer);
965 block_size = statfs_buffer.f_frsize;
968 if (statfs_result == -1)
972 g_set_error (error, G_IO_ERROR,
973 g_io_error_from_errno (errsv),
974 _("Error getting filesystem info: %s"),
979 info = g_file_info_new ();
981 attribute_matcher = g_file_attribute_matcher_new (attributes);
984 g_file_attribute_matcher_matches (attribute_matcher,
985 G_FILE_ATTRIBUTE_FILESYSTEM_FREE))
988 gchar *localdir = g_path_get_dirname (local->filename);
989 wchar_t *wdirname = g_utf8_to_utf16 (localdir, -1, NULL, NULL, NULL);
993 if (GetDiskFreeSpaceExW (wdirname, &li, NULL, NULL))
994 g_file_info_set_attribute_uint64 (info, G_FILE_ATTRIBUTE_FILESYSTEM_FREE, (guint64)li.QuadPart);
997 g_file_info_set_attribute_uint64 (info, G_FILE_ATTRIBUTE_FILESYSTEM_FREE, block_size * statfs_buffer.f_bavail);
1001 g_file_attribute_matcher_matches (attribute_matcher,
1002 G_FILE_ATTRIBUTE_FILESYSTEM_SIZE))
1005 gchar *localdir = g_path_get_dirname (local->filename);
1006 wchar_t *wdirname = g_utf8_to_utf16 (localdir, -1, NULL, NULL, NULL);
1010 if (GetDiskFreeSpaceExW (wdirname, NULL, &li, NULL))
1011 g_file_info_set_attribute_uint64 (info, G_FILE_ATTRIBUTE_FILESYSTEM_SIZE, (guint64)li.QuadPart);
1014 g_file_info_set_attribute_uint64 (info, G_FILE_ATTRIBUTE_FILESYSTEM_SIZE, block_size * statfs_buffer.f_blocks);
1018 #if defined(HAVE_STRUCT_STATFS_F_FSTYPENAME)
1019 fstype = g_strdup(statfs_buffer.f_fstypename);
1021 fstype = get_fs_type (statfs_buffer.f_type);
1024 #elif defined(USE_STATVFS) && defined(HAVE_STRUCT_STATVFS_F_BASETYPE)
1025 fstype = g_strdup(statfs_buffer.f_basetype);
1030 g_file_attribute_matcher_matches (attribute_matcher,
1031 G_FILE_ATTRIBUTE_FILESYSTEM_TYPE))
1032 g_file_info_set_attribute_string (info, G_FILE_ATTRIBUTE_FILESYSTEM_TYPE, fstype);
1035 if (g_file_attribute_matcher_matches (attribute_matcher,
1036 G_FILE_ATTRIBUTE_FILESYSTEM_READONLY))
1039 get_filesystem_readonly (info, local->filename);
1041 get_mount_info (info, local->filename, attribute_matcher);
1045 g_file_attribute_matcher_unref (attribute_matcher);
1051 g_local_file_find_enclosing_mount (GFile *file,
1052 GCancellable *cancellable,
1055 GLocalFile *local = G_LOCAL_FILE (file);
1060 if (g_lstat (local->filename, &buf) != 0)
1062 g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
1063 /* Translators: This is an error message when trying to
1064 * find the enclosing (user visible) mount of a file, but
1066 _("Containing mount does not exist"));
1070 mountpoint = find_mountpoint_for (local->filename, buf.st_dev);
1071 if (mountpoint == NULL)
1073 g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
1074 /* Translators: This is an error message when trying to
1075 * find the enclosing (user visible) mount of a file, but
1077 _("Containing mount does not exist"));
1081 mount = _g_mount_get_for_mount_path (mountpoint, cancellable);
1082 g_free (mountpoint);
1086 g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
1087 /* Translators: This is an error message when trying to find
1088 * the enclosing (user visible) mount of a file, but none
1090 _("Containing mount does not exist"));
1095 g_local_file_set_display_name (GFile *file,
1096 const char *display_name,
1097 GCancellable *cancellable,
1100 GLocalFile *local, *new_local;
1101 GFile *new_file, *parent;
1102 struct stat statbuf;
1105 parent = g_file_get_parent (file);
1108 g_set_error_literal (error, G_IO_ERROR,
1110 _("Can't rename root directory"));
1114 new_file = g_file_get_child_for_display_name (parent, display_name, error);
1115 g_object_unref (parent);
1117 if (new_file == NULL)
1120 local = G_LOCAL_FILE (file);
1121 new_local = G_LOCAL_FILE (new_file);
1123 if (!(g_lstat (new_local->filename, &statbuf) == -1 &&
1126 g_set_error_literal (error, G_IO_ERROR,
1128 _("Can't rename file, filename already exist"));
1132 if (g_rename (local->filename, new_local->filename) == -1)
1136 if (errsv == EINVAL)
1137 /* We can't get a rename file into itself error herer,
1138 so this must be an invalid filename, on e.g. FAT */
1139 g_set_error_literal (error, G_IO_ERROR,
1140 G_IO_ERROR_INVALID_FILENAME,
1141 _("Invalid filename"));
1143 g_set_error (error, G_IO_ERROR,
1144 g_io_error_from_errno (errsv),
1145 _("Error renaming file: %s"),
1146 g_strerror (errsv));
1147 g_object_unref (new_file);
1155 g_local_file_query_info (GFile *file,
1156 const char *attributes,
1157 GFileQueryInfoFlags flags,
1158 GCancellable *cancellable,
1161 GLocalFile *local = G_LOCAL_FILE (file);
1163 GFileAttributeMatcher *matcher;
1164 char *basename, *dirname;
1165 GLocalParentFileInfo parent_info;
1167 matcher = g_file_attribute_matcher_new (attributes);
1169 basename = g_path_get_basename (local->filename);
1171 dirname = g_path_get_dirname (local->filename);
1172 _g_local_file_info_get_parent_info (dirname, matcher, &parent_info);
1175 info = _g_local_file_info_get (basename, local->filename,
1176 matcher, flags, &parent_info,
1181 g_file_attribute_matcher_unref (matcher);
1186 static GFileAttributeInfoList *
1187 g_local_file_query_settable_attributes (GFile *file,
1188 GCancellable *cancellable,
1191 return g_file_attribute_info_list_ref (local_writable_attributes);
1194 static GFileAttributeInfoList *
1195 g_local_file_query_writable_namespaces (GFile *file,
1196 GCancellable *cancellable,
1199 return g_file_attribute_info_list_ref (local_writable_namespaces);
1203 g_local_file_set_attribute (GFile *file,
1204 const char *attribute,
1205 GFileAttributeType type,
1207 GFileQueryInfoFlags flags,
1208 GCancellable *cancellable,
1211 GLocalFile *local = G_LOCAL_FILE (file);
1213 return _g_local_file_info_set_attribute (local->filename,
1223 g_local_file_set_attributes_from_info (GFile *file,
1225 GFileQueryInfoFlags flags,
1226 GCancellable *cancellable,
1229 GLocalFile *local = G_LOCAL_FILE (file);
1230 int res, chained_res;
1231 GFileIface *default_iface;
1233 res = _g_local_file_info_set_attributes (local->filename,
1239 error = NULL; /* Don't write over error if further errors */
1241 default_iface = g_type_default_interface_peek (G_TYPE_FILE);
1243 chained_res = (default_iface->set_attributes_from_info) (file, info, flags, cancellable, error);
1245 return res && chained_res;
1248 static GFileInputStream *
1249 g_local_file_read (GFile *file,
1250 GCancellable *cancellable,
1253 GLocalFile *local = G_LOCAL_FILE (file);
1257 fd = g_open (local->filename, O_RDONLY|O_BINARY, 0);
1262 g_set_error (error, G_IO_ERROR,
1263 g_io_error_from_errno (errsv),
1264 _("Error opening file: %s"),
1265 g_strerror (errsv));
1269 if (fstat(fd, &buf) == 0 && S_ISDIR (buf.st_mode))
1272 g_set_error_literal (error, G_IO_ERROR,
1273 G_IO_ERROR_IS_DIRECTORY,
1274 _("Can't open directory"));
1278 return _g_local_file_input_stream_new (fd);
1281 static GFileOutputStream *
1282 g_local_file_append_to (GFile *file,
1283 GFileCreateFlags flags,
1284 GCancellable *cancellable,
1287 return _g_local_file_output_stream_append (G_LOCAL_FILE (file)->filename,
1288 flags, cancellable, error);
1291 static GFileOutputStream *
1292 g_local_file_create (GFile *file,
1293 GFileCreateFlags flags,
1294 GCancellable *cancellable,
1297 return _g_local_file_output_stream_create (G_LOCAL_FILE (file)->filename,
1298 flags, cancellable, error);
1301 static GFileOutputStream *
1302 g_local_file_replace (GFile *file,
1304 gboolean make_backup,
1305 GFileCreateFlags flags,
1306 GCancellable *cancellable,
1309 return _g_local_file_output_stream_replace (G_LOCAL_FILE (file)->filename,
1310 etag, make_backup, flags,
1311 cancellable, error);
1316 g_local_file_delete (GFile *file,
1317 GCancellable *cancellable,
1320 GLocalFile *local = G_LOCAL_FILE (file);
1322 if (g_remove (local->filename) == -1)
1326 /* Posix allows EEXIST too, but the more sane error
1327 is G_IO_ERROR_NOT_FOUND, and its what nautilus
1329 if (errsv == EEXIST)
1332 g_set_error (error, G_IO_ERROR,
1333 g_io_error_from_errno (errsv),
1334 _("Error removing file: %s"),
1335 g_strerror (errsv));
1343 strip_trailing_slashes (const char *path)
1348 path_copy = g_strdup (path);
1349 len = strlen (path_copy);
1350 while (len > 1 && path_copy[len-1] == '/')
1351 path_copy[--len] = 0;
1357 expand_symlink (const char *link)
1359 char *resolved, *canonical, *parent, *link2;
1360 char symlink_value[4096];
1368 res = readlink (link, symlink_value, sizeof (symlink_value) - 1);
1371 return g_strdup (link);
1372 symlink_value[res] = 0;
1375 if (g_path_is_absolute (symlink_value))
1376 return canonicalize_filename (symlink_value);
1379 link2 = strip_trailing_slashes (link);
1380 parent = g_path_get_dirname (link2);
1383 resolved = g_build_filename (parent, symlink_value, NULL);
1386 canonical = canonicalize_filename (resolved);
1395 get_parent (const char *path,
1399 struct stat parent_stat;
1403 path_copy = strip_trailing_slashes (path);
1405 parent = g_path_get_dirname (path_copy);
1406 if (strcmp (parent, ".") == 0 ||
1407 strcmp (parent, path_copy) == 0)
1417 if (g_lstat (parent, &parent_stat) != 0)
1423 if (S_ISLNK (parent_stat.st_mode))
1426 parent = expand_symlink (parent);
1431 if (num_recursions > 12)
1436 } while (S_ISLNK (parent_stat.st_mode));
1438 *parent_dev = parent_stat.st_dev;
1444 expand_all_symlinks (const char *path)
1446 char *parent, *parent_expanded;
1447 char *basename, *res;
1450 parent = get_parent (path, &parent_dev);
1453 parent_expanded = expand_all_symlinks (parent);
1455 basename = g_path_get_basename (path);
1456 res = g_build_filename (parent_expanded, basename, NULL);
1458 g_free (parent_expanded);
1461 res = g_strdup (path);
1469 find_mountpoint_for (const char *file,
1473 dev_t dir_dev, parent_dev;
1475 dir = g_strdup (file);
1480 parent = get_parent (dir, &parent_dev);
1484 if (parent_dev != dir_dev)
1496 find_topdir_for (const char *file)
1501 dir = get_parent (file, &dir_dev);
1505 return find_mountpoint_for (dir, dir_dev);
1509 get_unique_filename (const char *basename,
1515 return g_strdup (basename);
1517 dot = strchr (basename, '.');
1519 return g_strdup_printf ("%.*s.%d%s", (int)(dot - basename), basename, id, dot);
1521 return g_strdup_printf ("%s.%d", basename, id);
1525 path_has_prefix (const char *path,
1533 prefix_len = strlen (prefix);
1535 if (strncmp (path, prefix, prefix_len) == 0 &&
1536 (prefix_len == 0 || /* empty prefix always matches */
1537 prefix[prefix_len - 1] == '/' || /* last char in prefix was a /, so it must be in path too */
1538 path[prefix_len] == 0 ||
1539 path[prefix_len] == '/'))
1546 try_make_relative (const char *path,
1549 char *path2, *base2;
1552 path2 = expand_all_symlinks (path);
1553 base2 = expand_all_symlinks (base);
1556 if (path_has_prefix (path2, base2))
1558 relative = path2 + strlen (base2);
1559 while (*relative == '/')
1561 relative = g_strdup (relative);
1569 /* Failed, use abs path */
1570 return g_strdup (path);
1574 escape_trash_name (char *name)
1577 const gchar hex[16] = "0123456789ABCDEF";
1579 str = g_string_new ("");
1587 if (g_ascii_isprint (c))
1588 g_string_append_c (str, c);
1591 g_string_append_c (str, '%');
1592 g_string_append_c (str, hex[((guchar)c) >> 4]);
1593 g_string_append_c (str, hex[((guchar)c) & 0xf]);
1597 return g_string_free (str, FALSE);
1601 _g_local_file_has_trash_dir (const char *dirname, dev_t dir_dev)
1603 static gsize home_dev_set = 0;
1604 static dev_t home_dev;
1605 char *topdir, *globaldir, *trashdir, *tmpname;
1608 struct stat global_stat, trash_stat;
1612 if (g_once_init_enter (&home_dev_set))
1614 struct stat home_stat;
1616 g_stat (g_get_home_dir (), &home_stat);
1617 home_dev = home_stat.st_dev;
1618 g_once_init_leave (&home_dev_set, 1);
1621 /* Assume we can trash to the home */
1622 if (dir_dev == home_dev)
1625 topdir = find_mountpoint_for (dirname, dir_dev);
1629 globaldir = g_build_filename (topdir, ".Trash", NULL);
1630 statres = g_lstat (globaldir, &global_stat);
1631 if (g_lstat (globaldir, &global_stat) == 0 &&
1632 S_ISDIR (global_stat.st_mode) &&
1633 (global_stat.st_mode & S_ISVTX) != 0)
1635 /* got a toplevel sysadmin created dir, assume we
1636 * can trash to it (we should be able to create a dir)
1637 * This fails for the FAT case where the ownership of
1638 * that dir would be wrong though..
1646 /* No global trash dir, or it failed the tests, fall back to $topdir/.Trash-$uid */
1648 g_snprintf (uid_str, sizeof (uid_str), "%lu", (unsigned long) uid);
1650 tmpname = g_strdup_printf (".Trash-%s", uid_str);
1651 trashdir = g_build_filename (topdir, tmpname, NULL);
1654 if (g_lstat (trashdir, &trash_stat) == 0)
1659 S_ISDIR (trash_stat.st_mode) &&
1660 trash_stat.st_uid == uid;
1664 /* User specific trash didn't exist, can we create it? */
1665 res = g_access (topdir, W_OK) == 0;
1674 g_local_file_trash (GFile *file,
1675 GCancellable *cancellable,
1678 GLocalFile *local = G_LOCAL_FILE (file);
1679 struct stat file_stat, home_stat;
1680 const char *homedir;
1681 char *trashdir, *topdir, *infodir, *filesdir;
1682 char *basename, *trashname, *trashfile, *infoname, *infofile;
1683 char *original_name, *original_name_escaped;
1686 gboolean is_homedir_trash;
1687 char delete_time[32];
1689 struct stat trash_stat, global_stat;
1690 char *dirname, *globaldir;
1692 if (g_lstat (local->filename, &file_stat) != 0)
1696 g_set_error (error, G_IO_ERROR,
1697 g_io_error_from_errno (errsv),
1698 _("Error trashing file: %s"),
1699 g_strerror (errsv));
1703 homedir = g_get_home_dir ();
1704 g_stat (homedir, &home_stat);
1706 is_homedir_trash = FALSE;
1708 if (file_stat.st_dev == home_stat.st_dev)
1710 is_homedir_trash = TRUE;
1712 trashdir = g_build_filename (g_get_user_data_dir (), "Trash", NULL);
1713 if (g_mkdir_with_parents (trashdir, 0700) < 0)
1718 display_name = g_filename_display_name (trashdir);
1719 g_set_error (error, G_IO_ERROR,
1720 g_io_error_from_errno (errsv),
1721 _("Unable to create trash dir %s: %s"),
1722 display_name, g_strerror (errsv));
1723 g_free (display_name);
1727 topdir = g_strdup (g_get_user_data_dir ());
1735 g_snprintf (uid_str, sizeof (uid_str), "%lu", (unsigned long)uid);
1737 topdir = find_topdir_for (local->filename);
1740 g_set_error_literal (error, G_IO_ERROR,
1741 G_IO_ERROR_NOT_SUPPORTED,
1742 _("Unable to find toplevel directory for trash"));
1746 /* Try looking for global trash dir $topdir/.Trash/$uid */
1747 globaldir = g_build_filename (topdir, ".Trash", NULL);
1748 if (g_lstat (globaldir, &global_stat) == 0 &&
1749 S_ISDIR (global_stat.st_mode) &&
1750 (global_stat.st_mode & S_ISVTX) != 0)
1752 trashdir = g_build_filename (globaldir, uid_str, NULL);
1754 if (g_lstat (trashdir, &trash_stat) == 0)
1756 if (!S_ISDIR (trash_stat.st_mode) ||
1757 trash_stat.st_uid != uid)
1759 /* Not a directory or not owned by user, ignore */
1764 else if (g_mkdir (trashdir, 0700) == -1)
1772 if (trashdir == NULL)
1774 gboolean tried_create;
1776 /* No global trash dir, or it failed the tests, fall back to $topdir/.Trash-$uid */
1777 dirname = g_strdup_printf (".Trash-%s", uid_str);
1778 trashdir = g_build_filename (topdir, dirname, NULL);
1781 tried_create = FALSE;
1784 if (g_lstat (trashdir, &trash_stat) == 0)
1786 if (!S_ISDIR (trash_stat.st_mode) ||
1787 trash_stat.st_uid != uid)
1789 /* Remove the failed directory */
1791 g_remove (trashdir);
1793 /* Not a directory or not owned by user, ignore */
1800 if (!tried_create &&
1801 g_mkdir (trashdir, 0700) != -1)
1803 /* Ensure that the created dir has the right uid etc.
1804 This might fail on e.g. a FAT dir */
1805 tried_create = TRUE;
1816 if (trashdir == NULL)
1819 g_set_error_literal (error, G_IO_ERROR,
1820 G_IO_ERROR_NOT_SUPPORTED,
1821 _("Unable to find or create trash directory"));
1826 /* Trashdir points to the trash dir with the "info" and "files" subdirectories */
1828 infodir = g_build_filename (trashdir, "info", NULL);
1829 filesdir = g_build_filename (trashdir, "files", NULL);
1832 /* Make sure we have the subdirectories */
1833 if ((g_mkdir (infodir, 0700) == -1 && errno != EEXIST) ||
1834 (g_mkdir (filesdir, 0700) == -1 && errno != EEXIST))
1839 g_set_error_literal (error, G_IO_ERROR,
1840 G_IO_ERROR_NOT_SUPPORTED,
1841 _("Unable to find or create trash directory"));
1845 basename = g_path_get_basename (local->filename);
1853 trashname = get_unique_filename (basename, i++);
1854 infoname = g_strconcat (trashname, ".trashinfo", NULL);
1855 infofile = g_build_filename (infodir, infoname, NULL);
1858 fd = open (infofile, O_CREAT | O_EXCL, 0666);
1859 } while (fd == -1 && errno == EEXIST);
1873 g_set_error (error, G_IO_ERROR,
1874 g_io_error_from_errno (errsv),
1875 _("Unable to create trashing info file: %s"),
1876 g_strerror (errsv));
1882 /* TODO: Maybe we should verify that you can delete the file from the trash
1883 before moving it? OTOH, that is hard, as it needs a recursive scan */
1885 trashfile = g_build_filename (filesdir, trashname, NULL);
1889 if (g_rename (local->filename, trashfile) == -1)
1898 g_set_error (error, G_IO_ERROR,
1899 g_io_error_from_errno (errsv),
1900 _("Unable to trash file: %s"),
1901 g_strerror (errsv));
1907 /* TODO: Do we need to update mtime/atime here after the move? */
1909 /* Use absolute names for homedir */
1910 if (is_homedir_trash)
1911 original_name = g_strdup (local->filename);
1913 original_name = try_make_relative (local->filename, topdir);
1914 original_name_escaped = escape_trash_name (original_name);
1916 g_free (original_name);
1923 localtime_r (&t, &now);
1925 strftime(delete_time, sizeof (delete_time), "%Y-%m-%dT%H:%M:%S", &now);
1928 data = g_strdup_printf ("[Trash Info]\nPath=%s\nDeletionDate=%s\n",
1929 original_name_escaped, delete_time);
1931 g_file_set_contents (infofile, data, -1, NULL);
1935 g_free (original_name_escaped);
1940 #else /* G_OS_WIN32 */
1942 _g_local_file_has_trash_dir (const char *dirname, dev_t dir_dev)
1944 return FALSE; /* XXX ??? */
1948 g_local_file_trash (GFile *file,
1949 GCancellable *cancellable,
1952 GLocalFile *local = G_LOCAL_FILE (file);
1953 SHFILEOPSTRUCTW op = {0};
1958 wfilename = g_utf8_to_utf16 (local->filename, -1, NULL, &len, NULL);
1959 /* SHFILEOPSTRUCT.pFrom is double-zero-terminated */
1960 wfilename = g_renew (wchar_t, wfilename, len + 2);
1961 wfilename[len + 1] = 0;
1963 op.wFunc = FO_DELETE;
1964 op.pFrom = wfilename;
1965 op.fFlags = FOF_ALLOWUNDO;
1967 success = SHFileOperationW (&op) == 0;
1969 if (success && op.fAnyOperationsAborted)
1971 if (cancellable && !g_cancellable_is_cancelled (cancellable))
1972 g_cancellable_cancel (cancellable);
1973 g_set_error (error, G_IO_ERROR,
1974 G_IO_ERROR_CANCELLED,
1975 _("Unable to trash file: %s"),
1976 _("Operation was cancelled"));
1980 g_set_error (error, G_IO_ERROR,
1982 _("Unable to trash file: %s"),
1983 _("internal error"));
1988 #endif /* G_OS_WIN32 */
1991 g_local_file_make_directory (GFile *file,
1992 GCancellable *cancellable,
1995 GLocalFile *local = G_LOCAL_FILE (file);
1997 if (g_mkdir (local->filename, 0777) == -1)
2001 if (errsv == EINVAL)
2002 /* This must be an invalid filename, on e.g. FAT */
2003 g_set_error_literal (error, G_IO_ERROR,
2004 G_IO_ERROR_INVALID_FILENAME,
2005 _("Invalid filename"));
2007 g_set_error (error, G_IO_ERROR,
2008 g_io_error_from_errno (errsv),
2009 _("Error creating directory: %s"),
2010 g_strerror (errsv));
2018 g_local_file_make_symbolic_link (GFile *file,
2019 const char *symlink_value,
2020 GCancellable *cancellable,
2024 GLocalFile *local = G_LOCAL_FILE (file);
2026 if (symlink (symlink_value, local->filename) == -1)
2030 if (errsv == EINVAL)
2031 /* This must be an invalid filename, on e.g. FAT */
2032 g_set_error_literal (error, G_IO_ERROR,
2033 G_IO_ERROR_INVALID_FILENAME,
2034 _("Invalid filename"));
2036 g_set_error (error, G_IO_ERROR,
2037 g_io_error_from_errno (errsv),
2038 _("Error making symbolic link: %s"),
2039 g_strerror (errsv));
2044 g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, "Symlinks not supported");
2051 g_local_file_copy (GFile *source,
2053 GFileCopyFlags flags,
2054 GCancellable *cancellable,
2055 GFileProgressCallback progress_callback,
2056 gpointer progress_callback_data,
2059 /* Fall back to default copy */
2060 g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, "Copy not supported");
2065 g_local_file_move (GFile *source,
2067 GFileCopyFlags flags,
2068 GCancellable *cancellable,
2069 GFileProgressCallback progress_callback,
2070 gpointer progress_callback_data,
2073 GLocalFile *local_source, *local_destination;
2074 struct stat statbuf;
2075 gboolean destination_exist, source_is_dir;
2080 if (!G_IS_LOCAL_FILE (source) ||
2081 !G_IS_LOCAL_FILE (destination))
2083 /* Fall back to default move */
2084 g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, "Move not supported");
2088 local_source = G_LOCAL_FILE (source);
2089 local_destination = G_LOCAL_FILE (destination);
2091 res = g_lstat (local_source->filename, &statbuf);
2096 g_set_error (error, G_IO_ERROR,
2097 g_io_error_from_errno (errsv),
2098 _("Error moving file: %s"),
2099 g_strerror (errsv));
2103 source_is_dir = S_ISDIR (statbuf.st_mode);
2104 source_size = statbuf.st_size;
2106 destination_exist = FALSE;
2107 res = g_lstat (local_destination->filename, &statbuf);
2110 destination_exist = TRUE; /* Target file exists */
2112 if (flags & G_FILE_COPY_OVERWRITE)
2114 /* Always fail on dirs, even with overwrite */
2115 if (S_ISDIR (statbuf.st_mode))
2118 g_set_error_literal (error,
2120 G_IO_ERROR_WOULD_MERGE,
2121 _("Can't move directory over directory"));
2123 g_set_error_literal (error,
2125 G_IO_ERROR_IS_DIRECTORY,
2126 _("Can't copy over directory"));
2132 g_set_error_literal (error,
2135 _("Target file exists"));
2140 if (flags & G_FILE_COPY_BACKUP && destination_exist)
2142 backup_name = g_strconcat (local_destination->filename, "~", NULL);
2143 if (g_rename (local_destination->filename, backup_name) == -1)
2145 g_set_error_literal (error,
2147 G_IO_ERROR_CANT_CREATE_BACKUP,
2148 _("Backup file creation failed"));
2149 g_free (backup_name);
2152 g_free (backup_name);
2153 destination_exist = FALSE; /* It did, but no more */
2156 if (source_is_dir && destination_exist && (flags & G_FILE_COPY_OVERWRITE))
2158 /* Source is a dir, destination exists (and is not a dir, because that would have failed
2159 earlier), and we're overwriting. Manually remove the target so we can do the rename. */
2160 res = g_unlink (local_destination->filename);
2165 g_set_error (error, G_IO_ERROR,
2166 g_io_error_from_errno (errsv),
2167 _("Error removing target file: %s"),
2168 g_strerror (errsv));
2173 if (g_rename (local_source->filename, local_destination->filename) == -1)
2178 /* This will cause the fallback code to run */
2179 g_set_error_literal (error, G_IO_ERROR,
2180 G_IO_ERROR_NOT_SUPPORTED,
2181 _("Move between mounts not supported"));
2182 else if (errsv == EINVAL)
2183 /* This must be an invalid filename, on e.g. FAT, or
2184 we're trying to move the file into itself...
2185 We return invalid filename for both... */
2186 g_set_error_literal (error, G_IO_ERROR,
2187 G_IO_ERROR_INVALID_FILENAME,
2188 _("Invalid filename"));
2190 g_set_error (error, G_IO_ERROR,
2191 g_io_error_from_errno (errsv),
2192 _("Error moving file: %s"),
2193 g_strerror (errsv));
2197 /* Make sure we send full copied size */
2198 if (progress_callback)
2199 progress_callback (source_size, source_size, progress_callback_data);
2204 static GFileMonitor*
2205 g_local_file_monitor_dir (GFile *file,
2206 GFileMonitorFlags flags,
2207 GCancellable *cancellable,
2210 GLocalFile* local_file = G_LOCAL_FILE(file);
2211 return _g_local_directory_monitor_new (local_file->filename, flags, error);
2214 static GFileMonitor*
2215 g_local_file_monitor_file (GFile *file,
2216 GFileMonitorFlags flags,
2217 GCancellable *cancellable,
2220 GLocalFile* local_file = G_LOCAL_FILE(file);
2221 return _g_local_file_monitor_new (local_file->filename, flags, error);
2225 g_local_file_file_iface_init (GFileIface *iface)
2227 iface->dup = g_local_file_dup;
2228 iface->hash = g_local_file_hash;
2229 iface->equal = g_local_file_equal;
2230 iface->is_native = g_local_file_is_native;
2231 iface->has_uri_scheme = g_local_file_has_uri_scheme;
2232 iface->get_uri_scheme = g_local_file_get_uri_scheme;
2233 iface->get_basename = g_local_file_get_basename;
2234 iface->get_path = g_local_file_get_path;
2235 iface->get_uri = g_local_file_get_uri;
2236 iface->get_parse_name = g_local_file_get_parse_name;
2237 iface->get_parent = g_local_file_get_parent;
2238 iface->prefix_matches = g_local_file_prefix_matches;
2239 iface->get_relative_path = g_local_file_get_relative_path;
2240 iface->resolve_relative_path = g_local_file_resolve_relative_path;
2241 iface->get_child_for_display_name = g_local_file_get_child_for_display_name;
2242 iface->set_display_name = g_local_file_set_display_name;
2243 iface->enumerate_children = g_local_file_enumerate_children;
2244 iface->query_info = g_local_file_query_info;
2245 iface->query_filesystem_info = g_local_file_query_filesystem_info;
2246 iface->find_enclosing_mount = g_local_file_find_enclosing_mount;
2247 iface->query_settable_attributes = g_local_file_query_settable_attributes;
2248 iface->query_writable_namespaces = g_local_file_query_writable_namespaces;
2249 iface->set_attribute = g_local_file_set_attribute;
2250 iface->set_attributes_from_info = g_local_file_set_attributes_from_info;
2251 iface->read_fn = g_local_file_read;
2252 iface->append_to = g_local_file_append_to;
2253 iface->create = g_local_file_create;
2254 iface->replace = g_local_file_replace;
2255 iface->delete_file = g_local_file_delete;
2256 iface->trash = g_local_file_trash;
2257 iface->make_directory = g_local_file_make_directory;
2258 iface->make_symbolic_link = g_local_file_make_symbolic_link;
2259 iface->copy = g_local_file_copy;
2260 iface->move = g_local_file_move;
2261 iface->monitor_dir = g_local_file_monitor_dir;
2262 iface->monitor_file = g_local_file_monitor_file;