[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[augeas-devel] augeas: master - Pull computing a path underneath /files from a filename into a function



Gitweb:        http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=a393b972501abb7fcb17d761eef1d71f19b5a0d5
Commit:        a393b972501abb7fcb17d761eef1d71f19b5a0d5
Parent:        bc899802b65b9b429d726ed01ee5bbacd130cc80
Author:        David Lutterkort <lutter redhat com>
AuthorDate:    Thu Jan 7 11:27:06 2010 -0800
Committer:     David Lutterkort <lutter redhat com>
CommitterDate: Thu Jan 7 11:45:04 2010 -0800

Pull computing a path underneath /files from a filename into a function

  * src/transform.c (file_name_path): new function; (load_file): use
    file_name_path
---
 src/transform.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/src/transform.c b/src/transform.c
index e9adfc2..a73218c 100644
--- a/src/transform.c
+++ b/src/transform.c
@@ -382,6 +382,15 @@ static char *append_newline(char *text, size_t len) {
     return text;
 }
 
+/* Turn the file name FNAME, which starts with aug->root, into
+ * a path in the tree underneath /files */
+static char *file_name_path(struct augeas *aug, const char *fname) {
+    char *path = NULL;
+
+    pathjoin(&path, 2, AUGEAS_FILES_TREE, fname + strlen(aug->root) - 1);
+    return path;
+}
+
 static int load_file(struct augeas *aug, struct lens *lens,
                      const char *lens_name, char *filename) {
     char *text = NULL;
@@ -392,7 +401,8 @@ static int load_file(struct augeas *aug, struct lens *lens,
     struct lns_error *err = NULL;
     int result = -1, r;
 
-    pathjoin(&path, 2, AUGEAS_FILES_TREE, filename + strlen(aug->root) - 1);
+    path = file_name_path(aug, filename);
+    ERR_NOMEM(path == NULL, aug);
 
     r = add_file_info(aug, path, lens, lens_name);
     if (r < 0)
@@ -429,6 +439,7 @@ static int load_file(struct augeas *aug, struct lens *lens,
  done:
     store_error(aug, filename + strlen(aug->root) - 1, path, err_status,
                 errno, err, text);
+ error:
     free_lns_error(err);
     free(path);
     free_tree(tree);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]