core: Use ot_gfile_get_path_cached() pervasively

This requires no free() calls and is just better.
This commit is contained in:
Colin Walters committed 2011-11-17 18:23:36 -05:00
1 parent 8a24861763
commit a8735778f0
8 files changed
+38 -55

No files matched your search

+3 -4
View File
@@ -188,7 +188,7 @@ run_trigger (OstreeCheckout *self,
{
OstreeCheckoutPrivate *priv = GET_PRIVATE (self);
gboolean ret = FALSE;
char *path = NULL;
const char *path = NULL;
char *temp_path = NULL;
char *rel_temp_path = NULL;
GFile *temp_copy = NULL;
@@ -196,7 +196,7 @@ run_trigger (OstreeCheckout *self,
GPtrArray *args = NULL;
int estatus;
path = g_file_get_path (trigger);
path = ot_gfile_get_path_cached (trigger);
basename = g_path_get_basename (path);
args = g_ptr_array_new ();
@@ -217,7 +217,7 @@ run_trigger (OstreeCheckout *self,
}
else
{
g_ptr_array_add (args, path);
g_ptr_array_add (args, (char*)path);
g_ptr_array_add (args, NULL);
}
@@ -239,7 +239,6 @@ run_trigger (OstreeCheckout *self,
if (requires_chroot && temp_path)
(void)unlink (temp_path);
g_free (path);
g_free (basename);
g_free (temp_path);
g_free (rel_temp_path);
+2 -3
View File
@@ -462,7 +462,7 @@ ostree_pack_object (GOutputStream *output,
GError **error)
{
gboolean ret = FALSE;
char *path = NULL;
const char *path = NULL;
GFileInfo *finfo = NULL;
GFileInputStream *instream = NULL;
gboolean pack_builder_initialized = FALSE;
@@ -471,7 +471,7 @@ ostree_pack_object (GOutputStream *output,
GVariant *xattrs = NULL;
gsize bytes_written;
path = g_file_get_path (file);
path = ot_gfile_get_path_cached (file);
finfo = g_file_query_info (file, "standard::type,standard::size,standard::is-symlink,standard::symlink-target,unix::*",
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, cancellable, error);
@@ -590,7 +590,6 @@ ostree_pack_object (GOutputStream *output,
ret = TRUE;
out:
g_free (path);
g_clear_object (&finfo);
g_clear_object (&instream);
if (xattrs)
+12 -18
View File
@@ -106,10 +106,9 @@ ostree_repo_file_init (OstreeRepoFile *self)
static gboolean
set_error_noent (GFile *self, GError **error)
{
char *path = g_file_get_path (self);
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
"No such file or directory: %s", path);
g_free (path);
"No such file or directory: %s",
ot_gfile_get_path_cached (self));
return FALSE;
}
@@ -515,13 +514,12 @@ static char *
ostree_repo_file_get_uri (GFile *file)
{
OstreeRepoFile *self = OSTREE_REPO_FILE (file);
char *path;
const char *path;
char *uri_path;
char *ret;
path = g_file_get_path (file);
path = ot_gfile_get_path_cached (file);
uri_path = g_filename_to_uri (path, NULL, NULL);
g_free (path);
g_assert (g_str_has_prefix (uri_path, "file://"));
ret = g_strconcat ("ostree://", self->commit, uri_path+strlen("file://"), NULL);
g_free (uri_path);
@@ -609,14 +607,12 @@ ostree_repo_file_prefix_matches (GFile *parent,
GFile *descendant)
{
const char *remainder;
char *parent_path;
char *descendant_path;
const char *parent_path;
const char *descendant_path;
parent_path = g_file_get_path (parent);
descendant_path = g_file_get_path (descendant);
parent_path = ot_gfile_get_path_cached (parent);
descendant_path = ot_gfile_get_path_cached (descendant);
remainder = match_prefix (descendant_path, parent_path);
g_free (parent_path);
g_free (descendant_path);
if (remainder != NULL && G_IS_DIR_SEPARATOR (*remainder))
return TRUE;
return FALSE;
@@ -627,14 +623,12 @@ ostree_repo_file_get_relative_path (GFile *parent,
GFile *descendant)
{
const char *remainder;
char *parent_path;
char *descendant_path;
const char *parent_path;
const char *descendant_path;
parent_path = g_file_get_path (parent);
descendant_path = g_file_get_path (descendant);
parent_path = ot_gfile_get_path_cached (parent);
descendant_path = ot_gfile_get_path_cached (descendant);
remainder = match_prefix (descendant_path, parent_path);
g_free (parent_path);
g_free (descendant_path);
if (remainder != NULL && G_IS_DIR_SEPARATOR (*remainder))
return g_strdup (remainder + 1);
+7 -10
View File
@@ -215,16 +215,15 @@ parse_rev_file (OstreeRepo *self,
if (g_str_has_prefix (rev, "ref: "))
{
GFile *ref;
char *ref_path;
const char *ref_path;
char *ref_sha256;
gboolean subret;
ref = g_file_resolve_relative_path (priv->local_heads_dir, rev + 5);
ref_path = g_file_get_path (ref);
ref_path = ot_gfile_get_path_cached (ref);
subret = parse_rev_file (self, ref_path, &ref_sha256, error);
g_clear_object (&ref);
g_free (ref_path);
if (!subret)
{
@@ -263,7 +262,7 @@ ostree_repo_resolve_rev (OstreeRepo *self,
char *ret_rev = NULL;
GFile *child = NULL;
GFile *origindir = NULL;
char *child_path = NULL;
const char *child_path = NULL;
GError *temp_error = NULL;
GVariant *commit = NULL;
@@ -317,7 +316,7 @@ ostree_repo_resolve_rev (OstreeRepo *self,
else if (slash == NULL)
{
child = g_file_get_child (priv->local_heads_dir, rev);
child_path = g_file_get_path (child);
child_path = ot_gfile_get_path_cached (child);
}
else
{
@@ -331,7 +330,7 @@ ostree_repo_resolve_rev (OstreeRepo *self,
}
child = g_file_get_child (priv->remote_heads_dir, rev);
child_path = g_file_get_path (child);
child_path = ot_gfile_get_path_cached (child);
}
if (!ot_util_gfile_load_contents_utf8 (child, NULL, &ret_rev, NULL, &temp_error))
@@ -368,7 +367,6 @@ ostree_repo_resolve_rev (OstreeRepo *self,
g_free (tmp2);
g_clear_object (&child);
g_clear_object (&origindir);
g_free (child_path);
g_free (ret_rev);
return ret;
}
@@ -1554,9 +1552,9 @@ iter_object_dir (OstreeRepo *self,
GError *temp_error = NULL;
GFileEnumerator *enumerator = NULL;
GFileInfo *file_info = NULL;
char *dirpath = NULL;
const char *dirpath = NULL;
dirpath = g_file_get_path (dir);
dirpath = ot_gfile_get_path_cached (dir);
enumerator = g_file_enumerate_children (dir, OSTREE_GIO_FAST_QUERYINFO,
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
@@ -1603,7 +1601,6 @@ iter_object_dir (OstreeRepo *self,
ret = TRUE;
out:
g_free (dirpath);
return ret;
}