Rename currentDirectory() to rpmGetCwd() and move to librpmio
authorPanu Matilainen <pmatilai@redhat.com>
Fri, 4 Apr 2008 06:53:17 +0000 (09:53 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 4 Apr 2008 06:53:17 +0000 (09:53 +0300)
lib/misc.c
lib/misc.h
lib/query.c
lib/transaction.c
rpmio/rpmfileutil.c
rpmio/rpmfileutil.h

index 14b5ae4..3a2cb03 100644 (file)
@@ -70,17 +70,3 @@ int dosetenv(const char * name, const char * value, int overwrite)
     return putenv(a);
 }
 
-char * currentDirectory(void)
-{
-    int currDirLen = 0;
-    char * currDir = NULL;
-
-    do {
-       currDirLen += 128;
-       currDir = xrealloc(currDir, currDirLen);
-       memset(currDir, 0, currDirLen);
-    } while (getcwd(currDir, currDirLen) == NULL && errno == ERANGE);
-
-    return currDir;
-}
-
index 6881574..049b2ca 100644 (file)
@@ -38,12 +38,6 @@ int dosetenv(const char * name, const char * value, int overwrite);
  */
 int doputenv(const char * str);
 
-/**
- * Return (malloc'd) current working directory.
- * @return             current working directory (malloc'ed)
- */
-char * currentDirectory(void);
-
 #ifdef __cplusplus
 }
 #endif
index c365b19..460e644 100644 (file)
@@ -20,7 +20,6 @@
 #include <rpm/rpmfileutil.h>   /* rpmCleanPath */
 
 #include "lib/manifest.h"
-#include "lib/misc.h"          /* XXX for currentDirectory */
 
 #include "debug.h"
 
@@ -596,7 +595,7 @@ int rpmQueryVerify(QVA_t qva, rpmts ts, const char * arg)
            fn = realpath(arg, fnbuf);
            fn = xstrdup( (fn != NULL ? fn : arg) );
        } else if (*arg != '/') {
-           char *curDir = currentDirectory();
+           char *curDir = rpmGetCwd();
            fn = (char *) rpmGetPath(curDir, "/", arg, NULL);
            curDir = _free(curDir);
        } else
index 8550353..dcb6573 100644 (file)
@@ -20,7 +20,6 @@
 #include "lib/rpmte_internal.h"        /* XXX te->h, te->fd, te->h */
 #include "lib/rpmts_internal.h"
 #include "lib/cpio.h"
-#include "lib/misc.h"          /* currentDirectory */
 
 #include "debug.h"
 
@@ -1037,7 +1036,7 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
     }
 
     ts->ignoreSet = ignoreSet;
-    {  char * currDir = currentDirectory();
+    {  char * currDir = rpmGetCwd();
        rpmtsSetCurrDir(ts, currDir);
        currDir = _free(currDir);
     }
index ddd1b6f..93f6dc8 100644 (file)
@@ -766,3 +766,18 @@ int rpmFileHasSuffix(const char *path, const char *suffix)
     return (plen >= slen && 
            strcmp(path+plen-slen, suffix) == 0);
 }
+
+char * rpmGetCwd(void)
+{
+    int currDirLen = 0;
+    char * currDir = NULL;
+
+    do {
+       currDirLen += 128;
+       currDir = xrealloc(currDir, currDirLen);
+       memset(currDir, 0, currDirLen);
+    } while (getcwd(currDir, currDirLen) == NULL && errno == ERANGE);
+
+    return currDir;
+}
+
index 7c36484..37dd26a 100644 (file)
@@ -118,4 +118,10 @@ int rpmFileIsCompressed (const char * file, rpmCompressedMagic * compressed);
  */
 int rpmFileHasSuffix(const char *path, const char *suffix);
 
+/** \ingroup rpmfileutil
+ * Like getcwd() but the result is malloced.
+ * @return              current working directory (malloc'ed)
+ */
+char * rpmGetCwd(void);
+
 #endif /* _RPMFILEUTIL_H */