diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2008-04-04 09:53:17 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2008-04-04 09:53:17 +0300 |
commit | a5a3cfc3ed67083eaca0af0ffa48565a3e99bf57 (patch) | |
tree | 328767d80fcd9bb68f5b2929972b93ad5f52bde3 /rpmio | |
parent | 0bd84c940930b3752eedf967f8c842c270cb33f9 (diff) | |
download | rpm-a5a3cfc3ed67083eaca0af0ffa48565a3e99bf57.tar.gz rpm-a5a3cfc3ed67083eaca0af0ffa48565a3e99bf57.tar.bz2 rpm-a5a3cfc3ed67083eaca0af0ffa48565a3e99bf57.zip |
Rename currentDirectory() to rpmGetCwd() and move to librpmio
Diffstat (limited to 'rpmio')
-rw-r--r-- | rpmio/rpmfileutil.c | 15 | ||||
-rw-r--r-- | rpmio/rpmfileutil.h | 6 |
2 files changed, 21 insertions, 0 deletions
diff --git a/rpmio/rpmfileutil.c b/rpmio/rpmfileutil.c index ddd1b6f35..93f6dc8b1 100644 --- a/rpmio/rpmfileutil.c +++ b/rpmio/rpmfileutil.c @@ -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; +} + diff --git a/rpmio/rpmfileutil.h b/rpmio/rpmfileutil.h index 7c3648459..37dd26a55 100644 --- a/rpmio/rpmfileutil.h +++ b/rpmio/rpmfileutil.h @@ -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 */ |