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(sun) && defined(__SVR4)
57 /* on solaris, 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 "glocalfile.h"
76 #include "glocalfileinfo.h"
77 #include "glocalfileenumerator.h"
78 #include "glocalfileinputstream.h"
79 #include "glocalfileoutputstream.h"
80 #include "glocaldirectorymonitor.h"
81 #include "glocalfilemonitor.h"
82 #include "gmountprivate.h"
83 #include <glib/gstdio.h>
87 #define _WIN32_WINNT 0x0500
92 #ifndef FILE_READ_ONLY_VOLUME
93 #define FILE_READ_ONLY_VOLUME 0x00080000
97 #define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
100 #define S_ISLNK(m) (0)
104 #include "gioalias.h"
106 static void g_local_file_file_iface_init (GFileIface *iface);
108 static GFileAttributeInfoList *local_writable_attributes = NULL;
109 static GFileAttributeInfoList *local_writable_namespaces = NULL;
113 GObject parent_instance;
118 #define g_local_file_get_type _g_local_file_get_type
119 G_DEFINE_TYPE_WITH_CODE (GLocalFile, g_local_file, G_TYPE_OBJECT,
120 G_IMPLEMENT_INTERFACE (G_TYPE_FILE,
121 g_local_file_file_iface_init))
123 static char *find_mountpoint_for (const char *file, dev_t dev);
126 g_local_file_finalize (GObject *object)
130 local = G_LOCAL_FILE (object);
132 g_free (local->filename);
134 G_OBJECT_CLASS (g_local_file_parent_class)->finalize (object);
138 g_local_file_class_init (GLocalFileClass *klass)
140 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
141 GFileAttributeInfoList *list;
143 gobject_class->finalize = g_local_file_finalize;
145 /* Set up attribute lists */
147 /* Writable attributes: */
149 list = g_file_attribute_info_list_new ();
151 g_file_attribute_info_list_add (list,
152 G_FILE_ATTRIBUTE_UNIX_MODE,
153 G_FILE_ATTRIBUTE_TYPE_UINT32,
154 G_FILE_ATTRIBUTE_INFO_COPY_WITH_FILE |
155 G_FILE_ATTRIBUTE_INFO_COPY_WHEN_MOVED);
158 g_file_attribute_info_list_add (list,
159 G_FILE_ATTRIBUTE_UNIX_UID,
160 G_FILE_ATTRIBUTE_TYPE_UINT32,
161 G_FILE_ATTRIBUTE_INFO_COPY_WHEN_MOVED);
162 g_file_attribute_info_list_add (list,
163 G_FILE_ATTRIBUTE_UNIX_GID,
164 G_FILE_ATTRIBUTE_TYPE_UINT32,
165 G_FILE_ATTRIBUTE_INFO_COPY_WHEN_MOVED);
169 g_file_attribute_info_list_add (list,
170 G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET,
171 G_FILE_ATTRIBUTE_TYPE_BYTE_STRING,
176 g_file_attribute_info_list_add (list,
177 G_FILE_ATTRIBUTE_TIME_MODIFIED,
178 G_FILE_ATTRIBUTE_TYPE_UINT64,
179 G_FILE_ATTRIBUTE_INFO_COPY_WHEN_MOVED);
180 g_file_attribute_info_list_add (list,
181 G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC,
182 G_FILE_ATTRIBUTE_TYPE_UINT32,
183 G_FILE_ATTRIBUTE_INFO_COPY_WHEN_MOVED);
184 g_file_attribute_info_list_add (list,
185 G_FILE_ATTRIBUTE_TIME_ACCESS,
186 G_FILE_ATTRIBUTE_TYPE_UINT64,
187 G_FILE_ATTRIBUTE_INFO_COPY_WHEN_MOVED);
188 g_file_attribute_info_list_add (list,
189 G_FILE_ATTRIBUTE_TIME_ACCESS_USEC,
190 G_FILE_ATTRIBUTE_TYPE_UINT32,
191 G_FILE_ATTRIBUTE_INFO_COPY_WHEN_MOVED);
194 local_writable_attributes = list;
196 /* Writable namespaces: */
198 list = g_file_attribute_info_list_new ();
201 g_file_attribute_info_list_add (list,
203 G_FILE_ATTRIBUTE_TYPE_STRING,
204 G_FILE_ATTRIBUTE_INFO_COPY_WITH_FILE |
205 G_FILE_ATTRIBUTE_INFO_COPY_WHEN_MOVED);
206 g_file_attribute_info_list_add (list,
208 G_FILE_ATTRIBUTE_TYPE_STRING,
209 G_FILE_ATTRIBUTE_INFO_COPY_WHEN_MOVED);
212 local_writable_namespaces = list;
216 g_local_file_init (GLocalFile *local)
222 canonicalize_filename (const char *filename)
224 char *canon, *start, *p, *q;
228 if (!g_path_is_absolute (filename))
230 cwd = g_get_current_dir ();
231 canon = g_build_filename (cwd, filename, NULL);
235 canon = g_strdup (filename);
237 start = (char *)g_path_skip_root (canon);
239 /* POSIX allows double slashes at the start to
240 * mean something special (as does windows too).
241 * So, "//" != "/", but more than two slashes
247 G_IS_DIR_SEPARATOR (*p);
254 memmove (start, start+i, strlen (start+i)+1);
260 if (p[0] == '.' && (p[1] == 0 || G_IS_DIR_SEPARATOR (p[1])))
262 memmove (p, p+1, strlen (p+1)+1);
264 else if (p[0] == '.' && p[1] == '.' && (p[2] == 0 || G_IS_DIR_SEPARATOR (p[2])))
267 /* Skip previous separator */
271 while (p > start && !G_IS_DIR_SEPARATOR (*p))
273 if (G_IS_DIR_SEPARATOR (*p))
274 *p++ = G_DIR_SEPARATOR;
275 memmove (p, q, strlen (q)+1);
279 /* Skip until next separator */
280 while (*p != 0 && !G_IS_DIR_SEPARATOR (*p))
285 /* Canonicalize one separator */
286 *p++ = G_DIR_SEPARATOR;
290 /* Remove additional separators */
292 while (*q && G_IS_DIR_SEPARATOR (*q))
296 memmove (p, q, strlen (q)+1);
299 /* Remove trailing slashes */
300 if (p > start && G_IS_DIR_SEPARATOR (*(p-1)))
308 * @filename: filename of the file to create.
310 * Returns: new local #GFile.
313 _g_local_file_new (const char *filename)
317 local = g_object_new (G_TYPE_LOCAL_FILE, NULL);
318 local->filename = canonicalize_filename (filename);
320 return G_FILE (local);
324 g_local_file_is_native (GFile *file)
330 g_local_file_has_uri_scheme (GFile *file,
331 const char *uri_scheme)
333 return g_ascii_strcasecmp (uri_scheme, "file") == 0;
337 g_local_file_get_uri_scheme (GFile *file)
339 return g_strdup ("file");
343 g_local_file_get_basename (GFile *file)
345 return g_path_get_basename (G_LOCAL_FILE (file)->filename);
349 g_local_file_get_path (GFile *file)
351 return g_strdup (G_LOCAL_FILE (file)->filename);
355 g_local_file_get_uri (GFile *file)
357 return g_filename_to_uri (G_LOCAL_FILE (file)->filename, NULL, NULL);
361 get_filename_charset (const gchar **filename_charset)
363 const gchar **charsets;
366 is_utf8 = g_get_filename_charsets (&charsets);
368 if (filename_charset)
369 *filename_charset = charsets[0];
375 name_is_valid_for_display (const char *string,
376 gboolean is_valid_utf8)
380 if (!is_valid_utf8 &&
381 !g_utf8_validate (string, -1, NULL))
384 while ((c = *string++) != 0)
386 if (g_ascii_iscntrl (c))
394 g_local_file_get_parse_name (GFile *file)
396 const char *filename;
398 const gchar *charset;
400 char *roundtripped_filename;
401 gboolean free_utf8_filename;
402 gboolean is_valid_utf8;
405 filename = G_LOCAL_FILE (file)->filename;
406 if (get_filename_charset (&charset))
408 utf8_filename = (char *)filename;
409 free_utf8_filename = FALSE;
410 is_valid_utf8 = FALSE; /* Can't guarantee this */
414 utf8_filename = g_convert (filename, -1,
415 "UTF-8", charset, NULL, NULL, NULL);
416 free_utf8_filename = TRUE;
417 is_valid_utf8 = TRUE;
419 if (utf8_filename != NULL)
421 /* Make sure we can roundtrip: */
422 roundtripped_filename = g_convert (utf8_filename, -1,
423 charset, "UTF-8", NULL, NULL, NULL);
425 if (roundtripped_filename == NULL ||
426 strcmp (utf8_filename, roundtripped_filename) != 0)
428 g_free (utf8_filename);
429 utf8_filename = NULL;
434 if (utf8_filename != NULL &&
435 name_is_valid_for_display (utf8_filename, is_valid_utf8))
437 if (free_utf8_filename)
438 parse_name = utf8_filename;
440 parse_name = g_strdup (utf8_filename);
444 escaped_path = g_uri_escape_string (filename,
445 G_URI_RESERVED_CHARS_ALLOWED_IN_PATH_ELEMENT "/",
447 parse_name = g_strconcat ("file://",
448 (*escaped_path != '/') ? "/" : "",
452 g_free (escaped_path);
454 if (free_utf8_filename)
455 g_free (utf8_filename);
462 g_local_file_get_parent (GFile *file)
464 GLocalFile *local = G_LOCAL_FILE (file);
465 const char *non_root;
470 non_root = g_path_skip_root (local->filename);
474 dirname = g_path_get_dirname (local->filename);
475 parent = _g_local_file_new (dirname);
481 g_local_file_dup (GFile *file)
483 GLocalFile *local = G_LOCAL_FILE (file);
485 return _g_local_file_new (local->filename);
489 g_local_file_hash (GFile *file)
491 GLocalFile *local = G_LOCAL_FILE (file);
493 return g_str_hash (local->filename);
497 g_local_file_equal (GFile *file1,
500 GLocalFile *local1 = G_LOCAL_FILE (file1);
501 GLocalFile *local2 = G_LOCAL_FILE (file2);
503 return g_str_equal (local1->filename, local2->filename);
507 match_prefix (const char *path,
512 prefix_len = strlen (prefix);
513 if (strncmp (path, prefix, prefix_len) != 0)
516 /* Handle the case where prefix is the root, so that
517 * the IS_DIR_SEPRARATOR check below works */
518 if (prefix_len > 0 &&
519 G_IS_DIR_SEPARATOR (prefix[prefix_len-1]))
522 return path + prefix_len;
526 g_local_file_prefix_matches (GFile *parent,
529 GLocalFile *parent_local = G_LOCAL_FILE (parent);
530 GLocalFile *descendant_local = G_LOCAL_FILE (descendant);
531 const char *remainder;
533 remainder = match_prefix (descendant_local->filename, parent_local->filename);
534 if (remainder != NULL && G_IS_DIR_SEPARATOR (*remainder))
540 g_local_file_get_relative_path (GFile *parent,
543 GLocalFile *parent_local = G_LOCAL_FILE (parent);
544 GLocalFile *descendant_local = G_LOCAL_FILE (descendant);
545 const char *remainder;
547 remainder = match_prefix (descendant_local->filename, parent_local->filename);
549 if (remainder != NULL && G_IS_DIR_SEPARATOR (*remainder))
550 return g_strdup (remainder + 1);
555 g_local_file_resolve_relative_path (GFile *file,
556 const char *relative_path)
558 GLocalFile *local = G_LOCAL_FILE (file);
562 if (g_path_is_absolute (relative_path))
563 return _g_local_file_new (relative_path);
565 filename = g_build_filename (local->filename, relative_path, NULL);
566 child = _g_local_file_new (filename);
572 static GFileEnumerator *
573 g_local_file_enumerate_children (GFile *file,
574 const char *attributes,
575 GFileQueryInfoFlags flags,
576 GCancellable *cancellable,
579 GLocalFile *local = G_LOCAL_FILE (file);
580 return _g_local_file_enumerator_new (local,
586 g_local_file_get_child_for_display_name (GFile *file,
587 const char *display_name,
590 GFile *parent, *new_file;
593 basename = g_filename_from_utf8 (display_name, -1, NULL, NULL, NULL);
594 if (basename == NULL)
596 g_set_error (error, G_IO_ERROR,
597 G_IO_ERROR_INVALID_FILENAME,
598 _("Invalid filename %s"), display_name);
602 parent = g_file_get_parent (file);
603 new_file = g_file_get_child (file, basename);
604 g_object_unref (parent);
612 get_fs_type (long f_type)
615 /* filesystem ids taken from linux manpage */
716 G_LOCK_DEFINE_STATIC(mount_info_hash);
717 static GHashTable *mount_info_hash = NULL;
718 static guint64 mount_info_hash_cache_time = 0;
721 MOUNT_INFO_READONLY = 1<<0
725 device_equal (gconstpointer v1,
728 return *(dev_t *)v1 == *(dev_t *)v2;
732 device_hash (gconstpointer v)
734 return (guint) *(dev_t *)v;
738 get_mount_info (GFileInfo *fs_info,
740 GFileAttributeMatcher *matcher)
744 gpointer info_as_ptr;
748 GUnixMountEntry *mount;
751 if (g_lstat (path, &buf) != 0)
754 G_LOCK (mount_info_hash);
756 if (mount_info_hash == NULL)
757 mount_info_hash = g_hash_table_new_full (device_hash, device_equal,
761 if (g_unix_mounts_changed_since (mount_info_hash_cache_time))
762 g_hash_table_remove_all (mount_info_hash);
764 got_info = g_hash_table_lookup_extended (mount_info_hash,
769 G_UNLOCK (mount_info_hash);
771 mount_info = GPOINTER_TO_UINT (info_as_ptr);
777 mountpoint = find_mountpoint_for (path, buf.st_dev);
778 if (mountpoint == NULL)
781 mount = g_unix_mount_at (mountpoint, &cache_time);
784 if (g_unix_mount_is_readonly (mount))
785 mount_info |= MOUNT_INFO_READONLY;
787 g_unix_mount_free (mount);
790 dev = g_new0 (dev_t, 1);
793 G_LOCK (mount_info_hash);
794 mount_info_hash_cache_time = cache_time;
795 g_hash_table_insert (mount_info_hash, dev, GUINT_TO_POINTER (mount_info));
796 G_UNLOCK (mount_info_hash);
799 if (mount_info & MOUNT_INFO_READONLY)
800 g_file_info_set_attribute_boolean (fs_info, G_FILE_ATTRIBUTE_FILESYSTEM_READONLY, TRUE);
808 is_xp_or_later (void)
810 static int result = -1;
815 OSVERSIONINFOEX ver_info = {0};
816 DWORDLONG cond_mask = 0;
817 int op = VER_GREATER_EQUAL;
819 ver_info.dwOSVersionInfoSize = sizeof ver_info;
820 ver_info.dwMajorVersion = 5;
821 ver_info.dwMinorVersion = 1;
823 VER_SET_CONDITION (cond_mask, VER_MAJORVERSION, op);
824 VER_SET_CONDITION (cond_mask, VER_MINORVERSION, op);
826 result = VerifyVersionInfo (&ver_info,
827 VER_MAJORVERSION | VER_MINORVERSION,
830 result = ((DWORD)(LOBYTE (LOWORD (GetVersion ())))) >= 5;
838 get_volume_for_path (const char *path)
844 wpath = g_utf8_to_utf16 (path, -1, NULL, &len, NULL);
845 result = g_new (wchar_t, len + 2);
847 if (!GetVolumePathNameW (wpath, result, len + 2))
849 char *msg = g_win32_error_message (GetLastError ());
850 g_critical ("GetVolumePathName failed: %s", msg);
857 len = wcslen (result);
858 if (len > 0 && result[len-1] != L'\\')
860 result = g_renew (wchar_t, result, len + 2);
870 find_mountpoint_for (const char *file, dev_t dev)
875 wpath = get_volume_for_path (file);
879 utf8_path = g_utf16_to_utf8 (wpath, -1, NULL, NULL, NULL);
886 get_filesystem_readonly (GFileInfo *info,
891 rootdir = get_volume_for_path (path);
895 if (is_xp_or_later ())
898 if (GetVolumeInformationW (rootdir, NULL, 0, NULL, NULL, &flags, NULL, 0))
899 g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_FILESYSTEM_READONLY,
900 (flags & FILE_READ_ONLY_VOLUME) != 0);
904 if (GetDriveTypeW (rootdir) == DRIVE_CDROM)
905 g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_FILESYSTEM_READONLY, TRUE);
912 #endif /* G_OS_WIN32 */
915 g_local_file_query_filesystem_info (GFile *file,
916 const char *attributes,
917 GCancellable *cancellable,
920 GLocalFile *local = G_LOCAL_FILE (file);
922 int statfs_result = 0;
928 struct statfs statfs_buffer;
929 #elif defined(USE_STATVFS)
930 struct statvfs statfs_buffer;
933 GFileAttributeMatcher *attribute_matcher;
940 statfs_result = statfs (local->filename, &statfs_buffer);
941 #elif STATFS_ARGS == 4
942 statfs_result = statfs (local->filename, &statfs_buffer,
943 sizeof (statfs_buffer), 0);
945 block_size = statfs_buffer.f_bsize;
947 #if defined(__linux__)
948 /* ncpfs does not know the amount of available and free space *
949 * assuming ncpfs is linux specific, if you are on a non-linux platform
950 * where ncpfs is available, please file a bug about it on bugzilla.gnome.org
952 if (statfs_buffer.f_bavail == 0 && statfs_buffer.f_bfree == 0 &&
953 /* linux/ncp_fs.h: NCP_SUPER_MAGIC == 0x564c */
954 statfs_buffer.f_type == 0x564c)
958 #elif defined(USE_STATVFS)
959 statfs_result = statvfs (local->filename, &statfs_buffer);
960 block_size = statfs_buffer.f_frsize;
963 if (statfs_result == -1)
967 g_set_error (error, G_IO_ERROR,
968 g_io_error_from_errno (errsv),
969 _("Error getting filesystem info: %s"),
974 info = g_file_info_new ();
976 attribute_matcher = g_file_attribute_matcher_new (attributes);
979 g_file_attribute_matcher_matches (attribute_matcher,
980 G_FILE_ATTRIBUTE_FILESYSTEM_FREE))
983 gchar *localdir = g_path_get_dirname (local->filename);
984 wchar_t *wdirname = g_utf8_to_utf16 (localdir, -1, NULL, NULL, NULL);
988 if (GetDiskFreeSpaceExW (wdirname, &li, NULL, NULL))
989 g_file_info_set_attribute_uint64 (info, G_FILE_ATTRIBUTE_FILESYSTEM_FREE, (guint64)li.QuadPart);
992 g_file_info_set_attribute_uint64 (info, G_FILE_ATTRIBUTE_FILESYSTEM_FREE, block_size * statfs_buffer.f_bavail);
996 g_file_attribute_matcher_matches (attribute_matcher,
997 G_FILE_ATTRIBUTE_FILESYSTEM_SIZE))
1000 gchar *localdir = g_path_get_dirname (local->filename);
1001 wchar_t *wdirname = g_utf8_to_utf16 (localdir, -1, NULL, NULL, NULL);
1005 if (GetDiskFreeSpaceExW (wdirname, NULL, &li, NULL))
1006 g_file_info_set_attribute_uint64 (info, G_FILE_ATTRIBUTE_FILESYSTEM_SIZE, (guint64)li.QuadPart);
1009 g_file_info_set_attribute_uint64 (info, G_FILE_ATTRIBUTE_FILESYSTEM_SIZE, block_size * statfs_buffer.f_blocks);
1013 #if defined(HAVE_STRUCT_STATFS_F_FSTYPENAME)
1014 fstype = g_strdup(statfs_buffer.f_fstypename);
1016 fstype = get_fs_type (statfs_buffer.f_type);
1019 #elif defined(USE_STATVFS) && defined(HAVE_STRUCT_STATVFS_F_BASETYPE)
1020 fstype = g_strdup(statfs_buffer.f_basetype);
1025 g_file_attribute_matcher_matches (attribute_matcher,
1026 G_FILE_ATTRIBUTE_FILESYSTEM_TYPE))
1027 g_file_info_set_attribute_string (info, G_FILE_ATTRIBUTE_FILESYSTEM_TYPE, fstype);
1030 if (g_file_attribute_matcher_matches (attribute_matcher,
1031 G_FILE_ATTRIBUTE_FILESYSTEM_READONLY))
1034 get_filesystem_readonly (info, local->filename);
1036 get_mount_info (info, local->filename, attribute_matcher);
1040 g_file_attribute_matcher_unref (attribute_matcher);
1046 g_local_file_find_enclosing_mount (GFile *file,
1047 GCancellable *cancellable,
1050 GLocalFile *local = G_LOCAL_FILE (file);
1055 if (g_lstat (local->filename, &buf) != 0)
1057 g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
1058 /* Translators: This is an error message when trying to
1059 * find the enclosing (user visible) mount of a file, but
1061 _("Containing mount does not exist"));
1065 mountpoint = find_mountpoint_for (local->filename, buf.st_dev);
1066 if (mountpoint == NULL)
1068 g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
1069 /* Translators: This is an error message when trying to
1070 * find the enclosing (user visible) mount of a file, but
1072 _("Containing mount does not exist"));
1076 mount = _g_mount_get_for_mount_path (mountpoint, cancellable);
1077 g_free (mountpoint);
1081 g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
1082 /* Translators: This is an error message when trying to find
1083 * the enclosing (user visible) mount of a file, but none
1085 _("Containing mount does not exist"));
1090 g_local_file_set_display_name (GFile *file,
1091 const char *display_name,
1092 GCancellable *cancellable,
1095 GLocalFile *local, *new_local;
1096 GFile *new_file, *parent;
1097 struct stat statbuf;
1100 parent = g_file_get_parent (file);
1103 g_set_error_literal (error, G_IO_ERROR,
1105 _("Can't rename root directory"));
1109 new_file = g_file_get_child_for_display_name (parent, display_name, error);
1110 g_object_unref (parent);
1112 if (new_file == NULL)
1115 local = G_LOCAL_FILE (file);
1116 new_local = G_LOCAL_FILE (new_file);
1118 if (!(g_lstat (new_local->filename, &statbuf) == -1 &&
1121 g_set_error_literal (error, G_IO_ERROR,
1123 _("Can't rename file, filename already exist"));
1127 if (g_rename (local->filename, new_local->filename) == -1)
1131 if (errsv == EINVAL)
1132 /* We can't get a rename file into itself error herer,
1133 so this must be an invalid filename, on e.g. FAT */
1134 g_set_error_literal (error, G_IO_ERROR,
1135 G_IO_ERROR_INVALID_FILENAME,
1136 _("Invalid filename"));
1138 g_set_error (error, G_IO_ERROR,
1139 g_io_error_from_errno (errsv),
1140 _("Error renaming file: %s"),
1141 g_strerror (errsv));
1142 g_object_unref (new_file);
1150 g_local_file_query_info (GFile *file,
1151 const char *attributes,
1152 GFileQueryInfoFlags flags,
1153 GCancellable *cancellable,
1156 GLocalFile *local = G_LOCAL_FILE (file);
1158 GFileAttributeMatcher *matcher;
1159 char *basename, *dirname;
1160 GLocalParentFileInfo parent_info;
1162 matcher = g_file_attribute_matcher_new (attributes);
1164 basename = g_path_get_basename (local->filename);
1166 dirname = g_path_get_dirname (local->filename);
1167 _g_local_file_info_get_parent_info (dirname, matcher, &parent_info);
1170 info = _g_local_file_info_get (basename, local->filename,
1171 matcher, flags, &parent_info,
1176 g_file_attribute_matcher_unref (matcher);
1181 static GFileAttributeInfoList *
1182 g_local_file_query_settable_attributes (GFile *file,
1183 GCancellable *cancellable,
1186 return g_file_attribute_info_list_ref (local_writable_attributes);
1189 static GFileAttributeInfoList *
1190 g_local_file_query_writable_namespaces (GFile *file,
1191 GCancellable *cancellable,
1194 return g_file_attribute_info_list_ref (local_writable_namespaces);
1198 g_local_file_set_attribute (GFile *file,
1199 const char *attribute,
1200 GFileAttributeType type,
1202 GFileQueryInfoFlags flags,
1203 GCancellable *cancellable,
1206 GLocalFile *local = G_LOCAL_FILE (file);
1208 return _g_local_file_info_set_attribute (local->filename,
1218 g_local_file_set_attributes_from_info (GFile *file,
1220 GFileQueryInfoFlags flags,
1221 GCancellable *cancellable,
1224 GLocalFile *local = G_LOCAL_FILE (file);
1225 int res, chained_res;
1226 GFileIface *default_iface;
1228 res = _g_local_file_info_set_attributes (local->filename,
1234 error = NULL; /* Don't write over error if further errors */
1236 default_iface = g_type_default_interface_peek (G_TYPE_FILE);
1238 chained_res = (default_iface->set_attributes_from_info) (file, info, flags, cancellable, error);
1240 return res && chained_res;
1243 static GFileInputStream *
1244 g_local_file_read (GFile *file,
1245 GCancellable *cancellable,
1248 GLocalFile *local = G_LOCAL_FILE (file);
1252 fd = g_open (local->filename, O_RDONLY|O_BINARY, 0);
1257 g_set_error (error, G_IO_ERROR,
1258 g_io_error_from_errno (errsv),
1259 _("Error opening file: %s"),
1260 g_strerror (errsv));
1264 if (fstat(fd, &buf) == 0 && S_ISDIR (buf.st_mode))
1267 g_set_error_literal (error, G_IO_ERROR,
1268 G_IO_ERROR_IS_DIRECTORY,
1269 _("Can't open directory"));
1273 return _g_local_file_input_stream_new (fd);
1276 static GFileOutputStream *
1277 g_local_file_append_to (GFile *file,
1278 GFileCreateFlags flags,
1279 GCancellable *cancellable,
1282 return _g_local_file_output_stream_append (G_LOCAL_FILE (file)->filename,
1283 flags, cancellable, error);
1286 static GFileOutputStream *
1287 g_local_file_create (GFile *file,
1288 GFileCreateFlags flags,
1289 GCancellable *cancellable,
1292 return _g_local_file_output_stream_create (G_LOCAL_FILE (file)->filename,
1293 flags, cancellable, error);
1296 static GFileOutputStream *
1297 g_local_file_replace (GFile *file,
1299 gboolean make_backup,
1300 GFileCreateFlags flags,
1301 GCancellable *cancellable,
1304 return _g_local_file_output_stream_replace (G_LOCAL_FILE (file)->filename,
1305 etag, make_backup, flags,
1306 cancellable, error);
1311 g_local_file_delete (GFile *file,
1312 GCancellable *cancellable,
1315 GLocalFile *local = G_LOCAL_FILE (file);
1317 if (g_remove (local->filename) == -1)
1321 /* Posix allows EEXIST too, but the more sane error
1322 is G_IO_ERROR_NOT_FOUND, and its what nautilus
1324 if (errsv == EEXIST)
1327 g_set_error (error, G_IO_ERROR,
1328 g_io_error_from_errno (errsv),
1329 _("Error removing file: %s"),
1330 g_strerror (errsv));
1338 strip_trailing_slashes (const char *path)
1343 path_copy = g_strdup (path);
1344 len = strlen (path_copy);
1345 while (len > 1 && path_copy[len-1] == '/')
1346 path_copy[--len] = 0;
1352 expand_symlink (const char *link)
1354 char *resolved, *canonical, *parent, *link2;
1355 char symlink_value[4096];
1363 res = readlink (link, symlink_value, sizeof (symlink_value) - 1);
1366 return g_strdup (link);
1367 symlink_value[res] = 0;
1370 if (g_path_is_absolute (symlink_value))
1371 return canonicalize_filename (symlink_value);
1374 link2 = strip_trailing_slashes (link);
1375 parent = g_path_get_dirname (link2);
1378 resolved = g_build_filename (parent, symlink_value, NULL);
1381 canonical = canonicalize_filename (resolved);
1390 get_parent (const char *path,
1394 struct stat parent_stat;
1398 path_copy = strip_trailing_slashes (path);
1400 parent = g_path_get_dirname (path_copy);
1401 if (strcmp (parent, ".") == 0 ||
1402 strcmp (parent, path_copy) == 0)
1412 if (g_lstat (parent, &parent_stat) != 0)
1418 if (S_ISLNK (parent_stat.st_mode))
1421 parent = expand_symlink (parent);
1426 if (num_recursions > 12)
1431 } while (S_ISLNK (parent_stat.st_mode));
1433 *parent_dev = parent_stat.st_dev;
1439 expand_all_symlinks (const char *path)
1441 char *parent, *parent_expanded;
1442 char *basename, *res;
1445 parent = get_parent (path, &parent_dev);
1448 parent_expanded = expand_all_symlinks (parent);
1450 basename = g_path_get_basename (path);
1451 res = g_build_filename (parent_expanded, basename, NULL);
1453 g_free (parent_expanded);
1456 res = g_strdup (path);
1464 find_mountpoint_for (const char *file,
1468 dev_t dir_dev, parent_dev;
1470 dir = g_strdup (file);
1475 parent = get_parent (dir, &parent_dev);
1479 if (parent_dev != dir_dev)
1491 find_topdir_for (const char *file)
1496 dir = get_parent (file, &dir_dev);
1500 return find_mountpoint_for (dir, dir_dev);
1504 get_unique_filename (const char *basename,
1510 return g_strdup (basename);
1512 dot = strchr (basename, '.');
1514 return g_strdup_printf ("%.*s.%d%s", (int)(dot - basename), basename, id, dot);
1516 return g_strdup_printf ("%s.%d", basename, id);
1520 path_has_prefix (const char *path,
1528 prefix_len = strlen (prefix);
1530 if (strncmp (path, prefix, prefix_len) == 0 &&
1531 (prefix_len == 0 || /* empty prefix always matches */
1532 prefix[prefix_len - 1] == '/' || /* last char in prefix was a /, so it must be in path too */
1533 path[prefix_len] == 0 ||
1534 path[prefix_len] == '/'))
1541 try_make_relative (const char *path,
1544 char *path2, *base2;
1547 path2 = expand_all_symlinks (path);
1548 base2 = expand_all_symlinks (base);
1551 if (path_has_prefix (path2, base2))
1553 relative = path2 + strlen (base2);
1554 while (*relative == '/')
1556 relative = g_strdup (relative);
1564 /* Failed, use abs path */
1565 return g_strdup (path);
1569 escape_trash_name (char *name)
1572 const gchar hex[16] = "0123456789ABCDEF";
1574 str = g_string_new ("");
1582 if (g_ascii_isprint (c))
1583 g_string_append_c (str, c);
1586 g_string_append_c (str, '%');
1587 g_string_append_c (str, hex[((guchar)c) >> 4]);
1588 g_string_append_c (str, hex[((guchar)c) & 0xf]);
1592 return g_string_free (str, FALSE);
1596 _g_local_file_has_trash_dir (const char *dirname, dev_t dir_dev)
1598 static gsize home_dev_set = 0;
1599 static dev_t home_dev;
1600 char *topdir, *globaldir, *trashdir, *tmpname;
1603 struct stat global_stat, trash_stat;
1607 if (g_once_init_enter (&home_dev_set))
1609 struct stat home_stat;
1611 g_stat (g_get_home_dir (), &home_stat);
1612 home_dev = home_stat.st_dev;
1613 g_once_init_leave (&home_dev_set, 1);
1616 /* Assume we can trash to the home */
1617 if (dir_dev == home_dev)
1620 topdir = find_mountpoint_for (dirname, dir_dev);
1624 globaldir = g_build_filename (topdir, ".Trash", NULL);
1625 statres = g_lstat (globaldir, &global_stat);
1626 if (g_lstat (globaldir, &global_stat) == 0 &&
1627 S_ISDIR (global_stat.st_mode) &&
1628 (global_stat.st_mode & S_ISVTX) != 0)
1630 /* got a toplevel sysadmin created dir, assume we
1631 * can trash to it (we should be able to create a dir)
1632 * This fails for the FAT case where the ownership of
1633 * that dir would be wrong though..
1641 /* No global trash dir, or it failed the tests, fall back to $topdir/.Trash-$uid */
1643 g_snprintf (uid_str, sizeof (uid_str), "%lu", (unsigned long) uid);
1645 tmpname = g_strdup_printf (".Trash-%s", uid_str);
1646 trashdir = g_build_filename (topdir, tmpname, NULL);
1649 if (g_lstat (trashdir, &trash_stat) == 0)
1654 S_ISDIR (trash_stat.st_mode) &&
1655 trash_stat.st_uid == uid;
1659 /* User specific trash didn't exist, can we create it? */
1660 res = g_access (topdir, W_OK) == 0;
1669 g_local_file_trash (GFile *file,
1670 GCancellable *cancellable,
1673 GLocalFile *local = G_LOCAL_FILE (file);
1674 struct stat file_stat, home_stat;
1675 const char *homedir;
1676 char *trashdir, *topdir, *infodir, *filesdir;
1677 char *basename, *trashname, *trashfile, *infoname, *infofile;
1678 char *original_name, *original_name_escaped;
1681 gboolean is_homedir_trash;
1682 char delete_time[32];
1684 struct stat trash_stat, global_stat;
1685 char *dirname, *globaldir;
1687 if (g_lstat (local->filename, &file_stat) != 0)
1691 g_set_error (error, G_IO_ERROR,
1692 g_io_error_from_errno (errsv),
1693 _("Error trashing file: %s"),
1694 g_strerror (errsv));
1698 homedir = g_get_home_dir ();
1699 g_stat (homedir, &home_stat);
1701 is_homedir_trash = FALSE;
1703 if (file_stat.st_dev == home_stat.st_dev)
1705 is_homedir_trash = TRUE;
1707 trashdir = g_build_filename (g_get_user_data_dir (), "Trash", NULL);
1708 if (g_mkdir_with_parents (trashdir, 0700) < 0)
1713 display_name = g_filename_display_name (trashdir);
1714 g_set_error (error, G_IO_ERROR,
1715 g_io_error_from_errno (errsv),
1716 _("Unable to create trash dir %s: %s"),
1717 display_name, g_strerror (errsv));
1718 g_free (display_name);
1722 topdir = g_strdup (g_get_user_data_dir ());
1730 g_snprintf (uid_str, sizeof (uid_str), "%lu", (unsigned long)uid);
1732 topdir = find_topdir_for (local->filename);
1735 g_set_error_literal (error, G_IO_ERROR,
1736 G_IO_ERROR_NOT_SUPPORTED,
1737 _("Unable to find toplevel directory for trash"));
1741 /* Try looking for global trash dir $topdir/.Trash/$uid */
1742 globaldir = g_build_filename (topdir, ".Trash", NULL);
1743 if (g_lstat (globaldir, &global_stat) == 0 &&
1744 S_ISDIR (global_stat.st_mode) &&
1745 (global_stat.st_mode & S_ISVTX) != 0)
1747 trashdir = g_build_filename (globaldir, uid_str, NULL);
1749 if (g_lstat (trashdir, &trash_stat) == 0)
1751 if (!S_ISDIR (trash_stat.st_mode) ||
1752 trash_stat.st_uid != uid)
1754 /* Not a directory or not owned by user, ignore */
1759 else if (g_mkdir (trashdir, 0700) == -1)
1767 if (trashdir == NULL)
1769 gboolean tried_create;
1771 /* No global trash dir, or it failed the tests, fall back to $topdir/.Trash-$uid */
1772 dirname = g_strdup_printf (".Trash-%s", uid_str);
1773 trashdir = g_build_filename (topdir, dirname, NULL);
1776 tried_create = FALSE;
1779 if (g_lstat (trashdir, &trash_stat) == 0)
1781 if (!S_ISDIR (trash_stat.st_mode) ||
1782 trash_stat.st_uid != uid)
1784 /* Remove the failed directory */
1786 g_remove (trashdir);
1788 /* Not a directory or not owned by user, ignore */
1795 if (!tried_create &&
1796 g_mkdir (trashdir, 0700) != -1)
1798 /* Ensure that the created dir has the right uid etc.
1799 This might fail on e.g. a FAT dir */
1800 tried_create = TRUE;
1811 if (trashdir == NULL)
1814 g_set_error_literal (error, G_IO_ERROR,
1815 G_IO_ERROR_NOT_SUPPORTED,
1816 _("Unable to find or create trash directory"));
1821 /* Trashdir points to the trash dir with the "info" and "files" subdirectories */
1823 infodir = g_build_filename (trashdir, "info", NULL);
1824 filesdir = g_build_filename (trashdir, "files", NULL);
1827 /* Make sure we have the subdirectories */
1828 if ((g_mkdir (infodir, 0700) == -1 && errno != EEXIST) ||
1829 (g_mkdir (filesdir, 0700) == -1 && errno != EEXIST))
1834 g_set_error_literal (error, G_IO_ERROR,
1835 G_IO_ERROR_NOT_SUPPORTED,
1836 _("Unable to find or create trash directory"));
1840 basename = g_path_get_basename (local->filename);
1848 trashname = get_unique_filename (basename, i++);
1849 infoname = g_strconcat (trashname, ".trashinfo", NULL);
1850 infofile = g_build_filename (infodir, infoname, NULL);
1853 fd = open (infofile, O_CREAT | O_EXCL, 0666);
1854 } while (fd == -1 && errno == EEXIST);
1868 g_set_error (error, G_IO_ERROR,
1869 g_io_error_from_errno (errsv),
1870 _("Unable to create trashing info file: %s"),
1871 g_strerror (errsv));
1877 /* TODO: Maybe we should verify that you can delete the file from the trash
1878 before moving it? OTOH, that is hard, as it needs a recursive scan */
1880 trashfile = g_build_filename (filesdir, trashname, NULL);
1884 if (g_rename (local->filename, trashfile) == -1)
1893 g_set_error (error, G_IO_ERROR,
1894 g_io_error_from_errno (errsv),
1895 _("Unable to trash file: %s"),
1896 g_strerror (errsv));
1902 /* TODO: Do we need to update mtime/atime here after the move? */
1904 /* Use absolute names for homedir */
1905 if (is_homedir_trash)
1906 original_name = g_strdup (local->filename);
1908 original_name = try_make_relative (local->filename, topdir);
1909 original_name_escaped = escape_trash_name (original_name);
1911 g_free (original_name);
1918 localtime_r (&t, &now);
1920 strftime(delete_time, sizeof (delete_time), "%Y-%m-%dT%H:%M:%S", &now);
1923 data = g_strdup_printf ("[Trash Info]\nPath=%s\nDeletionDate=%s\n",
1924 original_name_escaped, delete_time);
1926 g_file_set_contents (infofile, data, -1, NULL);
1930 g_free (original_name_escaped);
1935 #else /* G_OS_WIN32 */
1937 _g_local_file_has_trash_dir (const char *dirname, dev_t dir_dev)
1939 return FALSE; /* XXX ??? */
1943 g_local_file_trash (GFile *file,
1944 GCancellable *cancellable,
1947 GLocalFile *local = G_LOCAL_FILE (file);
1948 SHFILEOPSTRUCTW op = {0};
1953 wfilename = g_utf8_to_utf16 (local->filename, -1, NULL, &len, NULL);
1954 /* SHFILEOPSTRUCT.pFrom is double-zero-terminated */
1955 wfilename = g_renew (wchar_t, wfilename, len + 2);
1956 wfilename[len + 1] = 0;
1958 op.wFunc = FO_DELETE;
1959 op.pFrom = wfilename;
1960 op.fFlags = FOF_ALLOWUNDO;
1962 success = SHFileOperationW (&op) == 0;
1964 if (success && op.fAnyOperationsAborted)
1966 if (cancellable && !g_cancellable_is_cancelled (cancellable))
1967 g_cancellable_cancel (cancellable);
1968 g_set_error (error, G_IO_ERROR,
1969 G_IO_ERROR_CANCELLED,
1970 _("Unable to trash file: %s"),
1971 _("Operation was cancelled"));
1975 g_set_error (error, G_IO_ERROR,
1977 _("Unable to trash file: %s"),
1978 _("internal error"));
1983 #endif /* G_OS_WIN32 */
1986 g_local_file_make_directory (GFile *file,
1987 GCancellable *cancellable,
1990 GLocalFile *local = G_LOCAL_FILE (file);
1992 if (g_mkdir (local->filename, 0755) == -1)
1996 if (errsv == EINVAL)
1997 /* This must be an invalid filename, on e.g. FAT */
1998 g_set_error_literal (error, G_IO_ERROR,
1999 G_IO_ERROR_INVALID_FILENAME,
2000 _("Invalid filename"));
2002 g_set_error (error, G_IO_ERROR,
2003 g_io_error_from_errno (errsv),
2004 _("Error creating directory: %s"),
2005 g_strerror (errsv));
2013 g_local_file_make_symbolic_link (GFile *file,
2014 const char *symlink_value,
2015 GCancellable *cancellable,
2019 GLocalFile *local = G_LOCAL_FILE (file);
2021 if (symlink (symlink_value, local->filename) == -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 making symbolic link: %s"),
2034 g_strerror (errsv));
2039 g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, "Symlinks not supported");
2046 g_local_file_copy (GFile *source,
2048 GFileCopyFlags flags,
2049 GCancellable *cancellable,
2050 GFileProgressCallback progress_callback,
2051 gpointer progress_callback_data,
2054 /* Fall back to default copy */
2055 g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, "Copy not supported");
2060 g_local_file_move (GFile *source,
2062 GFileCopyFlags flags,
2063 GCancellable *cancellable,
2064 GFileProgressCallback progress_callback,
2065 gpointer progress_callback_data,
2068 GLocalFile *local_source, *local_destination;
2069 struct stat statbuf;
2070 gboolean destination_exist, source_is_dir;
2075 if (!G_IS_LOCAL_FILE (source) ||
2076 !G_IS_LOCAL_FILE (destination))
2078 /* Fall back to default move */
2079 g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, "Move not supported");
2083 local_source = G_LOCAL_FILE (source);
2084 local_destination = G_LOCAL_FILE (destination);
2086 res = g_lstat (local_source->filename, &statbuf);
2091 g_set_error (error, G_IO_ERROR,
2092 g_io_error_from_errno (errsv),
2093 _("Error moving file: %s"),
2094 g_strerror (errsv));
2098 source_is_dir = S_ISDIR (statbuf.st_mode);
2099 source_size = statbuf.st_size;
2101 destination_exist = FALSE;
2102 res = g_lstat (local_destination->filename, &statbuf);
2105 destination_exist = TRUE; /* Target file exists */
2107 if (flags & G_FILE_COPY_OVERWRITE)
2109 /* Always fail on dirs, even with overwrite */
2110 if (S_ISDIR (statbuf.st_mode))
2113 g_set_error_literal (error,
2115 G_IO_ERROR_WOULD_MERGE,
2116 _("Can't move directory over directory"));
2118 g_set_error_literal (error,
2120 G_IO_ERROR_IS_DIRECTORY,
2121 _("Can't copy over directory"));
2127 g_set_error_literal (error,
2130 _("Target file exists"));
2135 if (flags & G_FILE_COPY_BACKUP && destination_exist)
2137 backup_name = g_strconcat (local_destination->filename, "~", NULL);
2138 if (g_rename (local_destination->filename, backup_name) == -1)
2140 g_set_error_literal (error,
2142 G_IO_ERROR_CANT_CREATE_BACKUP,
2143 _("Backup file creation failed"));
2144 g_free (backup_name);
2147 g_free (backup_name);
2148 destination_exist = FALSE; /* It did, but no more */
2151 if (source_is_dir && destination_exist && (flags & G_FILE_COPY_OVERWRITE))
2153 /* Source is a dir, destination exists (and is not a dir, because that would have failed
2154 earlier), and we're overwriting. Manually remove the target so we can do the rename. */
2155 res = g_unlink (local_destination->filename);
2160 g_set_error (error, G_IO_ERROR,
2161 g_io_error_from_errno (errsv),
2162 _("Error removing target file: %s"),
2163 g_strerror (errsv));
2168 if (g_rename (local_source->filename, local_destination->filename) == -1)
2173 /* This will cause the fallback code to run */
2174 g_set_error_literal (error, G_IO_ERROR,
2175 G_IO_ERROR_NOT_SUPPORTED,
2176 _("Move between mounts not supported"));
2177 else if (errsv == EINVAL)
2178 /* This must be an invalid filename, on e.g. FAT, or
2179 we're trying to move the file into itself...
2180 We return invalid filename for both... */
2181 g_set_error_literal (error, G_IO_ERROR,
2182 G_IO_ERROR_INVALID_FILENAME,
2183 _("Invalid filename"));
2185 g_set_error (error, G_IO_ERROR,
2186 g_io_error_from_errno (errsv),
2187 _("Error moving file: %s"),
2188 g_strerror (errsv));
2192 /* Make sure we send full copied size */
2193 if (progress_callback)
2194 progress_callback (source_size, source_size, progress_callback_data);
2199 static GFileMonitor*
2200 g_local_file_monitor_dir (GFile *file,
2201 GFileMonitorFlags flags,
2202 GCancellable *cancellable,
2205 GLocalFile* local_file = G_LOCAL_FILE(file);
2206 return _g_local_directory_monitor_new (local_file->filename, flags, error);
2209 static GFileMonitor*
2210 g_local_file_monitor_file (GFile *file,
2211 GFileMonitorFlags flags,
2212 GCancellable *cancellable,
2215 GLocalFile* local_file = G_LOCAL_FILE(file);
2216 return _g_local_file_monitor_new (local_file->filename, flags, error);
2220 g_local_file_file_iface_init (GFileIface *iface)
2222 iface->dup = g_local_file_dup;
2223 iface->hash = g_local_file_hash;
2224 iface->equal = g_local_file_equal;
2225 iface->is_native = g_local_file_is_native;
2226 iface->has_uri_scheme = g_local_file_has_uri_scheme;
2227 iface->get_uri_scheme = g_local_file_get_uri_scheme;
2228 iface->get_basename = g_local_file_get_basename;
2229 iface->get_path = g_local_file_get_path;
2230 iface->get_uri = g_local_file_get_uri;
2231 iface->get_parse_name = g_local_file_get_parse_name;
2232 iface->get_parent = g_local_file_get_parent;
2233 iface->prefix_matches = g_local_file_prefix_matches;
2234 iface->get_relative_path = g_local_file_get_relative_path;
2235 iface->resolve_relative_path = g_local_file_resolve_relative_path;
2236 iface->get_child_for_display_name = g_local_file_get_child_for_display_name;
2237 iface->set_display_name = g_local_file_set_display_name;
2238 iface->enumerate_children = g_local_file_enumerate_children;
2239 iface->query_info = g_local_file_query_info;
2240 iface->query_filesystem_info = g_local_file_query_filesystem_info;
2241 iface->find_enclosing_mount = g_local_file_find_enclosing_mount;
2242 iface->query_settable_attributes = g_local_file_query_settable_attributes;
2243 iface->query_writable_namespaces = g_local_file_query_writable_namespaces;
2244 iface->set_attribute = g_local_file_set_attribute;
2245 iface->set_attributes_from_info = g_local_file_set_attributes_from_info;
2246 iface->read_fn = g_local_file_read;
2247 iface->append_to = g_local_file_append_to;
2248 iface->create = g_local_file_create;
2249 iface->replace = g_local_file_replace;
2250 iface->delete_file = g_local_file_delete;
2251 iface->trash = g_local_file_trash;
2252 iface->make_directory = g_local_file_make_directory;
2253 iface->make_symbolic_link = g_local_file_make_symbolic_link;
2254 iface->copy = g_local_file_copy;
2255 iface->move = g_local_file_move;
2256 iface->monitor_dir = g_local_file_monitor_dir;
2257 iface->monitor_file = g_local_file_monitor_file;