/*
- $Id: ad_cp.c,v 1.1 2009-09-01 14:28:07 franklahm Exp $
-
Copyright (c) 2009 Frank Lahm <franklahm@gmail.com>
This program is free software; you can redistribute it and/or modify
}
-static void usage_cp()
+static void usage_cp(void)
{
printf(
"Usage: ad cp [-R [-L | -P]] [-pv] <source_file> <target_file>\n"
static int ad_cp_r(const afpvol_t *srcvol, const afpvol_t *dstvol, char *srcdir, char *dstdir)
{
- int ret = 0, cwd, dirprinted = 0, dirempty;
+ int ret = 0, dirprinted = 0, dirempty;
static char srcpath[MAXPATHLEN+1];
static char dstpath[MAXPATHLEN+1];
char *tmp;
- DIR *dp;
+ DIR *dp = NULL;
struct dirent *ep;
static struct stat st; /* Save some stack space */
}
exit:
- closedir(dp);
- fchdir(cwd);
- close(cwd);
-
+ if (dp)
+ closedir(dp);
+
if ((tmp = strrchr(srcpath, '/')))
*tmp = 0;
if ((tmp = strrchr(dstpath, '/')))