forked from AuroraMiddleware/gtk
g_path_skip_root() can return NULL; handle this. Fixes #129565.
2004-01-06 Federico Mena Quintero <federico@ximian.com> * gtk/gtkfilesystemunix.c (filename_is_root): g_path_skip_root() can return NULL; handle this. Fixes #129565.
This commit is contained in:
parent
caebaf94cb
commit
24b50606f9
@ -1,3 +1,8 @@
|
|||||||
|
2004-01-06 Federico Mena Quintero <federico@ximian.com>
|
||||||
|
|
||||||
|
* gtk/gtkfilesystemunix.c (filename_is_root): g_path_skip_root()
|
||||||
|
can return NULL; handle this. Fixes #129565.
|
||||||
|
|
||||||
2004-01-06 Alexander Winston <alexander.winston@comcast.net>
|
2004-01-06 Alexander Winston <alexander.winston@comcast.net>
|
||||||
|
|
||||||
* gtk/gtkfilesel.c: (gtk_file_selection_delete_file): Removed space
|
* gtk/gtkfilesel.c: (gtk_file_selection_delete_file): Removed space
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2004-01-06 Federico Mena Quintero <federico@ximian.com>
|
||||||
|
|
||||||
|
* gtk/gtkfilesystemunix.c (filename_is_root): g_path_skip_root()
|
||||||
|
can return NULL; handle this. Fixes #129565.
|
||||||
|
|
||||||
2004-01-06 Alexander Winston <alexander.winston@comcast.net>
|
2004-01-06 Alexander Winston <alexander.winston@comcast.net>
|
||||||
|
|
||||||
* gtk/gtkfilesel.c: (gtk_file_selection_delete_file): Removed space
|
* gtk/gtkfilesel.c: (gtk_file_selection_delete_file): Removed space
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2004-01-06 Federico Mena Quintero <federico@ximian.com>
|
||||||
|
|
||||||
|
* gtk/gtkfilesystemunix.c (filename_is_root): g_path_skip_root()
|
||||||
|
can return NULL; handle this. Fixes #129565.
|
||||||
|
|
||||||
2004-01-06 Alexander Winston <alexander.winston@comcast.net>
|
2004-01-06 Alexander Winston <alexander.winston@comcast.net>
|
||||||
|
|
||||||
* gtk/gtkfilesel.c: (gtk_file_selection_delete_file): Removed space
|
* gtk/gtkfilesel.c: (gtk_file_selection_delete_file): Removed space
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2004-01-06 Federico Mena Quintero <federico@ximian.com>
|
||||||
|
|
||||||
|
* gtk/gtkfilesystemunix.c (filename_is_root): g_path_skip_root()
|
||||||
|
can return NULL; handle this. Fixes #129565.
|
||||||
|
|
||||||
2004-01-06 Alexander Winston <alexander.winston@comcast.net>
|
2004-01-06 Alexander Winston <alexander.winston@comcast.net>
|
||||||
|
|
||||||
* gtk/gtkfilesel.c: (gtk_file_selection_delete_file): Removed space
|
* gtk/gtkfilesel.c: (gtk_file_selection_delete_file): Removed space
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2004-01-06 Federico Mena Quintero <federico@ximian.com>
|
||||||
|
|
||||||
|
* gtk/gtkfilesystemunix.c (filename_is_root): g_path_skip_root()
|
||||||
|
can return NULL; handle this. Fixes #129565.
|
||||||
|
|
||||||
2004-01-06 Alexander Winston <alexander.winston@comcast.net>
|
2004-01-06 Alexander Winston <alexander.winston@comcast.net>
|
||||||
|
|
||||||
* gtk/gtkfilesel.c: (gtk_file_selection_delete_file): Removed space
|
* gtk/gtkfilesel.c: (gtk_file_selection_delete_file): Removed space
|
||||||
|
@ -195,7 +195,7 @@ gtk_file_system_unix_get_type (void)
|
|||||||
0, /* n_preallocs */
|
0, /* n_preallocs */
|
||||||
(GInstanceInitFunc) gtk_file_system_unix_init,
|
(GInstanceInitFunc) gtk_file_system_unix_init,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const GInterfaceInfo file_system_info =
|
static const GInterfaceInfo file_system_info =
|
||||||
{
|
{
|
||||||
(GInterfaceInitFunc) gtk_file_system_unix_iface_init, /* interface_init */
|
(GInterfaceInitFunc) gtk_file_system_unix_iface_init, /* interface_init */
|
||||||
@ -216,11 +216,11 @@ gtk_file_system_unix_get_type (void)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* gtk_file_system_unix_new:
|
* gtk_file_system_unix_new:
|
||||||
*
|
*
|
||||||
* Creates a new #GtkFileSystemUnix object. #GtkFileSystemUnix
|
* Creates a new #GtkFileSystemUnix object. #GtkFileSystemUnix
|
||||||
* implements the #GtkFileSystem interface with direct access to
|
* implements the #GtkFileSystem interface with direct access to
|
||||||
* the filesystem using Unix/Linux API calls
|
* the filesystem using Unix/Linux API calls
|
||||||
*
|
*
|
||||||
* Return value: the new #GtkFileSystemUnix object
|
* Return value: the new #GtkFileSystemUnix object
|
||||||
**/
|
**/
|
||||||
GtkFileSystem *
|
GtkFileSystem *
|
||||||
@ -235,7 +235,7 @@ gtk_file_system_unix_class_init (GtkFileSystemUnixClass *class)
|
|||||||
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
|
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
|
||||||
|
|
||||||
system_parent_class = g_type_class_peek_parent (class);
|
system_parent_class = g_type_class_peek_parent (class);
|
||||||
|
|
||||||
gobject_class->finalize = gtk_file_system_unix_finalize;
|
gobject_class->finalize = gtk_file_system_unix_finalize;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -296,7 +296,7 @@ gtk_file_system_unix_get_root_info (GtkFileSystem *file_system,
|
|||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
const gchar *filename = gtk_file_path_get_string (path);
|
const gchar *filename = gtk_file_path_get_string (path);
|
||||||
|
|
||||||
g_return_val_if_fail (strcmp (filename, "/") == 0, NULL);
|
g_return_val_if_fail (strcmp (filename, "/") == 0, NULL);
|
||||||
|
|
||||||
return filename_get_info ("/", types, error);
|
return filename_get_info ("/", types, error);
|
||||||
@ -331,9 +331,9 @@ gtk_file_system_unix_create_folder (GtkFileSystem *file_system,
|
|||||||
|
|
||||||
filename = filename_from_path (path);
|
filename = filename_from_path (path);
|
||||||
g_return_val_if_fail (filename != NULL, FALSE);
|
g_return_val_if_fail (filename != NULL, FALSE);
|
||||||
|
|
||||||
result = mkdir (filename, 0777) != 0;
|
result = mkdir (filename, 0777) != 0;
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
gchar *filename_utf8 = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL);
|
gchar *filename_utf8 = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL);
|
||||||
@ -345,9 +345,9 @@ gtk_file_system_unix_create_folder (GtkFileSystem *file_system,
|
|||||||
g_strerror (errno));
|
g_strerror (errno));
|
||||||
g_free (filename_utf8);
|
g_free (filename_utf8);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (filename);
|
g_free (filename);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -376,7 +376,7 @@ gtk_file_system_unix_volume_get_is_mounted (GtkFileSystem *file_system,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gtk_file_system_unix_volume_mount (GtkFileSystem *file_system,
|
gtk_file_system_unix_volume_mount (GtkFileSystem *file_system,
|
||||||
GtkFileSystemVolume *volume,
|
GtkFileSystemVolume *volume,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
@ -440,7 +440,7 @@ gtk_file_system_unix_make_path (GtkFileSystem *file_system,
|
|||||||
gchar *full_filename;
|
gchar *full_filename;
|
||||||
GError *tmp_error = NULL;
|
GError *tmp_error = NULL;
|
||||||
GtkFilePath *result;
|
GtkFilePath *result;
|
||||||
|
|
||||||
base_filename = filename_from_path (base_path);
|
base_filename = filename_from_path (base_path);
|
||||||
g_return_val_if_fail (base_filename != NULL, NULL);
|
g_return_val_if_fail (base_filename != NULL, NULL);
|
||||||
|
|
||||||
@ -452,19 +452,19 @@ gtk_file_system_unix_make_path (GtkFileSystem *file_system,
|
|||||||
GTK_FILE_SYSTEM_ERROR_BAD_FILENAME,
|
GTK_FILE_SYSTEM_ERROR_BAD_FILENAME,
|
||||||
"%s",
|
"%s",
|
||||||
tmp_error->message);
|
tmp_error->message);
|
||||||
|
|
||||||
g_error_free (tmp_error);
|
g_error_free (tmp_error);
|
||||||
g_free (base_filename);
|
g_free (base_filename);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
full_filename = g_build_filename (base_filename, filename, NULL);
|
full_filename = g_build_filename (base_filename, filename, NULL);
|
||||||
result = filename_to_path (full_filename);
|
result = filename_to_path (full_filename);
|
||||||
g_free (base_filename);
|
g_free (base_filename);
|
||||||
g_free (filename);
|
g_free (filename);
|
||||||
g_free (full_filename);
|
g_free (full_filename);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -499,7 +499,7 @@ canonicalize_filename (gchar *filename)
|
|||||||
{
|
{
|
||||||
if (*(p + 1) == '\0')
|
if (*(p + 1) == '\0')
|
||||||
break;
|
break;
|
||||||
|
|
||||||
p += 1;
|
p += 1;
|
||||||
}
|
}
|
||||||
else if (*(p + 1) == '.' &&
|
else if (*(p + 1) == '.' &&
|
||||||
@ -516,7 +516,7 @@ canonicalize_filename (gchar *filename)
|
|||||||
|
|
||||||
if (*(p + 2) == '\0')
|
if (*(p + 2) == '\0')
|
||||||
break;
|
break;
|
||||||
|
|
||||||
p += 2;
|
p += 2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -555,7 +555,7 @@ gtk_file_system_unix_parse (GtkFileSystem *file_system,
|
|||||||
|
|
||||||
base_filename = filename_from_path (base_path);
|
base_filename = filename_from_path (base_path);
|
||||||
g_return_val_if_fail (base_filename != NULL, FALSE);
|
g_return_val_if_fail (base_filename != NULL, FALSE);
|
||||||
|
|
||||||
last_slash = strrchr (str, G_DIR_SEPARATOR);
|
last_slash = strrchr (str, G_DIR_SEPARATOR);
|
||||||
if (!last_slash)
|
if (!last_slash)
|
||||||
{
|
{
|
||||||
@ -595,7 +595,7 @@ gtk_file_system_unix_parse (GtkFileSystem *file_system,
|
|||||||
}
|
}
|
||||||
|
|
||||||
canonicalize_filename (folder_path);
|
canonicalize_filename (folder_path);
|
||||||
|
|
||||||
*folder = filename_to_path (folder_path);
|
*folder = filename_to_path (folder_path);
|
||||||
*file_part = g_strdup (last_slash + 1);
|
*file_part = g_strdup (last_slash + 1);
|
||||||
|
|
||||||
@ -606,7 +606,7 @@ gtk_file_system_unix_parse (GtkFileSystem *file_system,
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_free (base_filename);
|
g_free (base_filename);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -712,7 +712,7 @@ gtk_file_folder_unix_get_type (void)
|
|||||||
0, /* n_preallocs */
|
0, /* n_preallocs */
|
||||||
(GInstanceInitFunc) gtk_file_folder_unix_init,
|
(GInstanceInitFunc) gtk_file_folder_unix_init,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const GInterfaceInfo file_folder_info =
|
static const GInterfaceInfo file_folder_info =
|
||||||
{
|
{
|
||||||
(GInterfaceInitFunc) gtk_file_folder_unix_iface_init, /* interface_init */
|
(GInterfaceInitFunc) gtk_file_folder_unix_iface_init, /* interface_init */
|
||||||
@ -759,7 +759,7 @@ gtk_file_folder_unix_finalize (GObject *object)
|
|||||||
GtkFileFolderUnix *folder_unix = GTK_FILE_FOLDER_UNIX (object);
|
GtkFileFolderUnix *folder_unix = GTK_FILE_FOLDER_UNIX (object);
|
||||||
|
|
||||||
g_free (folder_unix->filename);
|
g_free (folder_unix->filename);
|
||||||
|
|
||||||
folder_parent_class->finalize (object);
|
folder_parent_class->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -772,7 +772,7 @@ gtk_file_folder_unix_get_info (GtkFileFolder *folder,
|
|||||||
GtkFileInfo *info;
|
GtkFileInfo *info;
|
||||||
gchar *dirname;
|
gchar *dirname;
|
||||||
gchar *filename;
|
gchar *filename;
|
||||||
|
|
||||||
filename = filename_from_path (path);
|
filename = filename_from_path (path);
|
||||||
g_return_val_if_fail (filename != NULL, NULL);
|
g_return_val_if_fail (filename != NULL, NULL);
|
||||||
|
|
||||||
@ -806,7 +806,7 @@ gtk_file_folder_unix_list_children (GtkFileFolder *folder,
|
|||||||
GTK_FILE_SYSTEM_ERROR_NONEXISTENT,
|
GTK_FILE_SYSTEM_ERROR_NONEXISTENT,
|
||||||
"%s",
|
"%s",
|
||||||
tmp_error->message);
|
tmp_error->message);
|
||||||
|
|
||||||
g_error_free (tmp_error);
|
g_error_free (tmp_error);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -828,7 +828,7 @@ gtk_file_folder_unix_list_children (GtkFileFolder *folder,
|
|||||||
g_dir_close (dir);
|
g_dir_close (dir);
|
||||||
|
|
||||||
*children = g_slist_reverse (*children);
|
*children = g_slist_reverse (*children);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -842,7 +842,7 @@ filename_get_info (const gchar *filename,
|
|||||||
GtkFileIconType icon_type = GTK_FILE_ICON_REGULAR;
|
GtkFileIconType icon_type = GTK_FILE_ICON_REGULAR;
|
||||||
#endif
|
#endif
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
|
|
||||||
/* If stat fails, try to fall back to lstat to catch broken links
|
/* If stat fails, try to fall back to lstat to catch broken links
|
||||||
*/
|
*/
|
||||||
if (stat (filename, &statbuf) != 0 &&
|
if (stat (filename, &statbuf) != 0 &&
|
||||||
@ -856,7 +856,7 @@ filename_get_info (const gchar *filename,
|
|||||||
filename_utf8 ? filename_utf8 : "???",
|
filename_utf8 ? filename_utf8 : "???",
|
||||||
g_strerror (errno));
|
g_strerror (errno));
|
||||||
g_free (filename_utf8);
|
g_free (filename_utf8);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -866,25 +866,25 @@ filename_get_info (const gchar *filename,
|
|||||||
{
|
{
|
||||||
if (types & GTK_FILE_INFO_DISPLAY_NAME)
|
if (types & GTK_FILE_INFO_DISPLAY_NAME)
|
||||||
gtk_file_info_set_display_name (info, "/");
|
gtk_file_info_set_display_name (info, "/");
|
||||||
|
|
||||||
if (types & GTK_FILE_INFO_IS_HIDDEN)
|
if (types & GTK_FILE_INFO_IS_HIDDEN)
|
||||||
gtk_file_info_set_is_hidden (info, FALSE);
|
gtk_file_info_set_is_hidden (info, FALSE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gchar *basename = g_path_get_basename (filename);
|
gchar *basename = g_path_get_basename (filename);
|
||||||
|
|
||||||
if (types & GTK_FILE_INFO_DISPLAY_NAME)
|
if (types & GTK_FILE_INFO_DISPLAY_NAME)
|
||||||
{
|
{
|
||||||
gchar *display_name = g_filename_to_utf8 (basename, -1, NULL, NULL, NULL);
|
gchar *display_name = g_filename_to_utf8 (basename, -1, NULL, NULL, NULL);
|
||||||
if (!display_name)
|
if (!display_name)
|
||||||
display_name = g_strescape (basename, NULL);
|
display_name = g_strescape (basename, NULL);
|
||||||
|
|
||||||
gtk_file_info_set_display_name (info, display_name);
|
gtk_file_info_set_display_name (info, display_name);
|
||||||
|
|
||||||
g_free (display_name);
|
g_free (display_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (types & GTK_FILE_INFO_IS_HIDDEN)
|
if (types & GTK_FILE_INFO_IS_HIDDEN)
|
||||||
{
|
{
|
||||||
gtk_file_info_set_is_hidden (info, basename[0] == '.');
|
gtk_file_info_set_is_hidden (info, basename[0] == '.');
|
||||||
@ -945,7 +945,7 @@ filename_get_info (const gchar *filename,
|
|||||||
{
|
{
|
||||||
gtk_file_info_set_size (info, (gint64)statbuf.st_size);
|
gtk_file_info_set_size (info, (gint64)statbuf.st_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -965,8 +965,8 @@ static gboolean
|
|||||||
filename_is_root (const char *filename)
|
filename_is_root (const char *filename)
|
||||||
{
|
{
|
||||||
const gchar *after_root;
|
const gchar *after_root;
|
||||||
|
|
||||||
after_root = g_path_skip_root (filename);
|
after_root = g_path_skip_root (filename);
|
||||||
|
|
||||||
return (*after_root == '\0');
|
return (after_root != NULL && *after_root == '\0');
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user