diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2008-05-03 12:34:19 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2008-05-03 12:34:19 +0300 |
commit | 0ee67fede81600dad90da5139f6109399d6926e7 (patch) | |
tree | bcb7affad40208cbee23dbc3902e80f9fdd832b1 /rpmio/rpmfileutil.c | |
parent | 87ea239ffc5763b1d85ce1b0d35759d9bafe1cb5 (diff) | |
download | librpm-tizen-0ee67fede81600dad90da5139f6109399d6926e7.tar.gz librpm-tizen-0ee67fede81600dad90da5139f6109399d6926e7.tar.bz2 librpm-tizen-0ee67fede81600dad90da5139f6109399d6926e7.zip |
Temp file handling tweaks
- rename rpmMkTemp() (back) to rpmMkTempFile()
- rpmMkTemp() is now a lower level thin wrapper around mkstemp()
Diffstat (limited to 'rpmio/rpmfileutil.c')
-rw-r--r-- | rpmio/rpmfileutil.c | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/rpmio/rpmfileutil.c b/rpmio/rpmfileutil.c index 64510e991..93c5cd52f 100644 --- a/rpmio/rpmfileutil.c +++ b/rpmio/rpmfileutil.c @@ -225,11 +225,27 @@ exit: return rc; } -FD_t rpmMkTemp(const char * prefix, char **fn) +FD_t rpmMkTemp(char *template) +{ + int sfd; + FD_t tfd = NULL; + + sfd = mkstemp(template); + if (sfd < 0) { + goto exit; + } + + tfd = fdDup(sfd); + close(sfd); + +exit: + return tfd; +} + +FD_t rpmMkTempFile(const char * prefix, char **fn) { const char *tpmacro = "%{_tmppath}"; /* always set from rpmrc */ char *tempfn; - int sfd; static int _initialized = 0; FD_t tfd = NULL; @@ -245,16 +261,10 @@ FD_t rpmMkTemp(const char * prefix, char **fn) } tempfn = rpmGetPath(prefix, tpmacro, "/rpm-tmp.XXXXXX", NULL); - sfd = mkstemp(tempfn); - if (sfd < 0) { - rpmlog(RPMLOG_ERR, _("error creating temporary file: %m\n")); - goto exit; - } + tfd = rpmMkTemp(tempfn); - tfd = fdDup(sfd); - close(sfd); if (tfd == NULL || Ferror(tfd)) { - rpmlog(RPMLOG_ERR, _("error opening temporary file %s: %m\n"), tempfn); + rpmlog(RPMLOG_ERR, _("error creating temporary file %s: %m\n"), tempfn); goto exit; } |