Add a helper function for remote locations

Add a helper function that says whether a location should be
considered remote. To determine this, we look at the filesystem
type reported by gvfs, and say 'remote' for sftp, webdav, ftp,
nfs and cifs.
This commit is contained in:
Matthias Clasen 2015-07-24 16:01:25 -04:00
parent 30de4cc7bb
commit 93bfec3ac5
2 changed files with 33 additions and 0 deletions

View File

@ -921,3 +921,34 @@ _gtk_file_has_native_path (GFile *file)
return has_native_path;
}
static const gchar * const remote_types[] = {
"sftp",
"webdav",
"ftp",
"nfs",
"cifs",
NULL
};
gboolean
_gtk_file_consider_as_remote (GFile *file)
{
GFileInfo *info;
gboolean is_remote;
info = g_file_query_filesystem_info (file, "filesystem::type", NULL, NULL);
if (info)
{
const gchar *type;
type = g_file_info_get_attribute_string (info, "filesystem::type");
is_remote = g_strv_contains (remote_types, type);
g_object_unref (info);
}
else
is_remote = FALSE;
return is_remote;
}

View File

@ -118,6 +118,8 @@ gboolean _gtk_file_info_consider_as_directory (GFileInfo *info);
/* GFile helper functions */
gboolean _gtk_file_has_native_path (GFile *file);
gboolean _gtk_file_consider_as_remote (GFile *file);
G_END_DECLS
#endif /* __GTK_FILE_SYSTEM_H__ */