Final excision of libgsystem dependency
Lots and lots of preparation led to this moment - when nothing apparent changes for users! Woo! But seriously, having the extra dependency is a minor annoyance, and in the big picture I think the libgsystem idea was wrong - we need to land things in GLib, and use git submodules for API-unstable or Linux-specific sharing. For a lot of OSTree, the libgsystem `GFile*` orientation was also wrong, we really want fd-relative. Closes: #444 Approved by: jlebon
This commit is contained in:
1 parent
fd9536bb19
commit
a29bb0ab6b
11 files changed
+50
-29
No files matched your search
@@ -463,3 +463,39 @@ ot_file_enumerator_iterate (GFileEnumerator *direnum,
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
G_LOCK_DEFINE_STATIC (pathname_cache);
|
||||
|
||||
/**
|
||||
* ot_file_get_path_cached:
|
||||
*
|
||||
* Like g_file_get_path(), but returns a constant copy so callers
|
||||
* don't need to free the result.
|
||||
*/
|
||||
const char *
|
||||
ot_file_get_path_cached (GFile *file)
|
||||
{
|
||||
const char *path;
|
||||
static GQuark _file_path_quark = 0;
|
||||
|
||||
if (G_UNLIKELY (_file_path_quark) == 0)
|
||||
_file_path_quark = g_quark_from_static_string ("gsystem-file-path");
|
||||
|
||||
G_LOCK (pathname_cache);
|
||||
|
||||
path = g_object_get_qdata ((GObject*)file, _file_path_quark);
|
||||
if (!path)
|
||||
{
|
||||
path = g_file_get_path (file);
|
||||
if (path == NULL)
|
||||
{
|
||||
G_UNLOCK (pathname_cache);
|
||||
return NULL;
|
||||
}
|
||||
g_object_set_qdata_full ((GObject*)file, _file_path_quark, (char*)path, (GDestroyNotify)g_free);
|
||||
}
|
||||
|
||||
G_UNLOCK (pathname_cache);
|
||||
|
||||
return path;
|
||||
}
|
||||
Reference in new issue
Block a user