otutil: Add some more GIO helpers
This commit is contained in:
parent
eb288bab9d
commit
7a67b17cd2
|
|
@ -146,3 +146,32 @@ ot_util_new_file_for_path (const char *path)
|
||||||
{
|
{
|
||||||
return g_vfs_get_file_for_path (g_vfs_get_local (), path);
|
return g_vfs_get_file_for_path (g_vfs_get_local (), path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
ot_gfile_get_path_cached (GFile *file)
|
||||||
|
{
|
||||||
|
const char *path;
|
||||||
|
|
||||||
|
path = g_object_get_data ((GObject*)file, "ostree-file-path");
|
||||||
|
if (!path)
|
||||||
|
{
|
||||||
|
path = g_file_get_path (file);
|
||||||
|
g_object_set_data_full ((GObject*)file, "ostree-file-path", (char*)path, (GDestroyNotify)g_free);
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char *
|
||||||
|
ot_gfile_get_basename_cached (GFile *file)
|
||||||
|
{
|
||||||
|
const char *name;
|
||||||
|
|
||||||
|
name = g_object_get_data ((GObject*)file, "ostree-file-name");
|
||||||
|
if (!name)
|
||||||
|
{
|
||||||
|
name = g_file_get_basename (file);
|
||||||
|
g_object_set_data_full ((GObject*)file, "ostree-file-name", (char*)name, (GDestroyNotify)g_free);
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,10 @@ G_BEGIN_DECLS
|
||||||
|
|
||||||
GFile *ot_util_new_file_for_path (const char *path);
|
GFile *ot_util_new_file_for_path (const char *path);
|
||||||
|
|
||||||
|
const char *ot_gfile_get_path_cached (GFile *file);
|
||||||
|
|
||||||
|
const char *ot_gfile_get_basename_cached (GFile *file);
|
||||||
|
|
||||||
gboolean ot_util_ensure_directory (const char *path, gboolean with_parents, GError **error);
|
gboolean ot_util_ensure_directory (const char *path, gboolean with_parents, GError **error);
|
||||||
|
|
||||||
char * ot_util_get_file_contents_utf8 (const char *path, GError **error);
|
char * ot_util_get_file_contents_utf8 (const char *path, GError **error);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue