aboutsummaryrefslogtreecommitdiff
path: root/src/diskio.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-05-10 23:12:02 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2011-05-11 00:28:52 +0300
commitdb81e378576dcc5510032c72060e48e562f208c9 (patch)
tree914c5f277a5fad050527a5c5da815f521e8023dc /src/diskio.c
parent84db86f0151385a8f05483bf691fde86b4e4e153 (diff)
downloadwydawca-db81e378576dcc5510032c72060e48e562f208c9.tar.gz
wydawca-db81e378576dcc5510032c72060e48e562f208c9.tar.bz2
Remove save-cwd.
* src/pushd.c: New file. * src/Makefile.am: Add pushd.c * src/wydawca.h (push_dir, pop_dir): New functions. * src/diskio.c: Use push_dir/pop_dir. * src/exec.c: Likewise. * src/gpg.c: Likewise. * gnulib.modules: Remove save-cwd. * tests/pushck.c: New file. * tests/pushdir.at: New file. * tests/testsuite.at: Add pushdir.at * tests/Makefile.am: Likewise. * tests/.gitignore: Add pushck.
Diffstat (limited to 'src/diskio.c')
-rw-r--r--src/diskio.c24
1 files changed, 7 insertions, 17 deletions
diff --git a/src/diskio.c b/src/diskio.c
index ed16e35..9addd9b 100644
--- a/src/diskio.c
+++ b/src/diskio.c
@@ -15,7 +15,6 @@
with wydawca. If not, see <http://www.gnu.org/licenses/>. */
#include "wydawca.h"
-#include "save-cwd.h"
/* Return true if ARG is NULL or is a sub-directory of DIR */
int
@@ -529,7 +528,6 @@ dir_symlink_file (struct file_triplet *trp,
const char *wanted_src, const char *wanted_dst)
{
int rc = 0;
- struct saved_cwd cwd;
const struct spool *spool = trp->spool;
char *dst_dir = create_directory (spool->dest_dir, trp->relative_dir);
char *src, *dst;
@@ -537,13 +535,6 @@ dir_symlink_file (struct file_triplet *trp,
if (!dst_dir)
return 1;
- if (save_cwd (&cwd))
- {
- logmsg (LOG_ERR, _("cannot save current directory: %s"),
- strerror (errno));
- return 1;
- }
-
src = safe_file_name_alloc (wanted_src);
if (!src || src[0] == '/')
{
@@ -585,7 +576,7 @@ dir_symlink_file (struct file_triplet *trp,
if (rc == 0)
{
- if (chdir (dst_dir))
+ if (push_dir (dst_dir))
logmsg (LOG_ERR, _("cannot change to %s: %s"),
dst_dir, strerror (errno));
else
@@ -625,17 +616,16 @@ dir_symlink_file (struct file_triplet *trp,
_("symlinking %s to %s in directory %s failed: %s"),
src, dst, dst_dir, strerror (errno));
}
+ if (pop_dir ())
+ {
+ logmsg (LOG_EMERG, _("cannot restore current directory: %s"),
+ strerror (errno));
+ exit (EX_SOFTWARE);
+ }
}
}
}
- if (restore_cwd (&cwd))
- {
- logmsg (LOG_EMERG, _("cannot restore current directory: %s"),
- strerror (errno));
- exit (EX_SOFTWARE);
- }
-
free (src);
free (dst);
free (dst_dir);

Return to:

Send suggestions and report system problems to the System administrator.