]> arthur.barton.de Git - netatalk.git/blobdiff - bin/cnid/ad_cp.c
call readt with ONE_DELAY = 5 s
[netatalk.git] / bin / cnid / ad_cp.c
index e2f2472b8c25abab56b859c51cbdf8a6ba9a5a10..938ce1b41ab267ba41cab7d6c45929fa8eb67271 100644 (file)
@@ -1,6 +1,4 @@
 /* 
-   $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
@@ -73,7 +71,7 @@ static const char *check_netatalk_dirs(const char *name)
 }
 
 
-static void usage_cp()
+static void usage_cp(void)
 {
     printf(
         "Usage: ad cp [-R [-L | -P]] [-pv] <source_file> <target_file>\n"
@@ -90,11 +88,11 @@ static int ad_cp_copy(const afpvol_t *srcvol, const afpvol_t *dstvol,
 
 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 */
 
@@ -165,10 +163,9 @@ static int ad_cp_r(const afpvol_t *srcvol, const afpvol_t *dstvol, char *srcdir,
     }
 
 exit:
-    closedir(dp);
-    fchdir(cwd);
-    close(cwd);
-
+    if (dp)
+        closedir(dp);
     if ((tmp = strrchr(srcpath, '/')))
         *tmp = 0;
     if ((tmp = strrchr(dstpath, '/')))