core: Add helper functions to convert (checksum, objtype) pair to/from string
This commit is contained in:
1 parent
277843f3a2
commit
70afd6011f
4 files changed
+38
-32
No files matched your search
@@ -564,6 +564,26 @@ ostree_object_type_from_string (const char *str)
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *
|
||||
ostree_object_to_string (const char *checksum,
|
||||
OstreeObjectType objtype)
|
||||
{
|
||||
return g_strconcat (checksum, ".", ostree_object_type_to_string (objtype), NULL);
|
||||
}
|
||||
|
||||
void
|
||||
ostree_object_from_string (const char *str,
|
||||
gchar **out_checksum,
|
||||
OstreeObjectType *out_objtype)
|
||||
{
|
||||
const char *dot;
|
||||
|
||||
dot = strrchr (str, '.');
|
||||
g_assert (dot != NULL);
|
||||
*out_checksum = g_strndup (str, dot - str);
|
||||
*out_objtype = ostree_object_type_from_string (dot + 1);
|
||||
}
|
||||
|
||||
char *
|
||||
ostree_get_relative_object_path (const char *checksum,
|
||||
OstreeObjectType type)
|
||||
|
||||
Reference in new issue
Block a user