mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
ges-formatter: Check if directory of URI is writeable
https://bugzilla.gnome.org/show_bug.cgi?id=679941
This commit is contained in:
parent
eab86c2913
commit
9d30f05798
1 changed files with 37 additions and 0 deletions
|
@ -276,6 +276,10 @@ ges_formatter_can_load_uri (const gchar * uri, GError ** error)
|
||||||
gboolean
|
gboolean
|
||||||
ges_formatter_can_save_uri (const gchar * uri, GError ** error)
|
ges_formatter_can_save_uri (const gchar * uri, GError ** error)
|
||||||
{
|
{
|
||||||
|
GFile *file = NULL;
|
||||||
|
GFile *dir = NULL;
|
||||||
|
GFileInfo *info = NULL;
|
||||||
|
|
||||||
if (!(gst_uri_is_valid (uri))) {
|
if (!(gst_uri_is_valid (uri))) {
|
||||||
GST_ERROR ("%s invalid uri!", uri);
|
GST_ERROR ("%s invalid uri!", uri);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -288,6 +292,39 @@ ges_formatter_can_save_uri (const gchar * uri, GError ** error)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check if URI or parent directory is writeable */
|
||||||
|
file = g_file_new_for_uri (uri);
|
||||||
|
|
||||||
|
if (g_file_query_file_type (file, G_FILE_QUERY_INFO_NONE, NULL)
|
||||||
|
== G_FILE_TYPE_DIRECTORY) {
|
||||||
|
dir = file;
|
||||||
|
} else {
|
||||||
|
dir = g_file_get_parent (file);
|
||||||
|
|
||||||
|
if (dir == NULL)
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
info = g_file_query_info (dir, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE,
|
||||||
|
G_FILE_QUERY_INFO_NONE, NULL, error);
|
||||||
|
|
||||||
|
if (error && *error != NULL) {
|
||||||
|
GST_ERROR ("Unable to write to directory: %s", (*error)->message);
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
} else {
|
||||||
|
gboolean writeable = g_file_info_get_attribute_boolean (info,
|
||||||
|
G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE);
|
||||||
|
if (!writeable) {
|
||||||
|
GST_ERROR ("Unable to write to directory");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
g_object_unref (file);
|
||||||
|
g_object_unref (dir);
|
||||||
|
g_object_unref (info);
|
||||||
|
|
||||||
/* TODO: implement file format registry */
|
/* TODO: implement file format registry */
|
||||||
/* TODO: search through the registry and chose a GESFormatter class that can
|
/* TODO: search through the registry and chose a GESFormatter class that can
|
||||||
* handle the URI.*/
|
* handle the URI.*/
|
||||||
|
|
Loading…
Reference in a new issue