Rename currentDirectory() to rpmGetCwd() and move to librpmio

This commit is contained in:
Panu Matilainen 2008-04-04 09:53:17 +03:00
parent 0bd84c9409
commit a5a3cfc3ed
6 changed files with 23 additions and 24 deletions

View 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;
}

View 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

View 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

View 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);
}

View 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;
}

View 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 */