static int nonprompt = 0, quiet = 0, dots = 0, keep_permissions = 0, verbose = 0, send_stdout = 0;
static int blocksize = SMB_DEFAULT_BLOCKSIZE;
-static int smb_download_file(const char *base, const char *name, int recursive, int resume, char *outfile);
+static int smb_download_file(const char *base, const char *name, int recursive,
+ int resume, int toplevel, char *outfile);
static int get_num_cols(void)
{
/* List files in directory and call smb_download_file on them */
dirhandle = smbc_opendir(path);
if(dirhandle < 1) {
- if(errno == ENOTDIR) return smb_download_file(base, name, 1, resume, NULL);
+ if (errno == ENOTDIR) {
+ return smb_download_file(base, name, 1, resume,
+ 0, NULL);
+ }
fprintf(stderr, "Can't open directory %s: %s\n", path, strerror(errno));
return 1;
}
break;
case SMBC_FILE:
- ret = smb_download_file(base, newname, 1, resume, NULL);
+ ret = smb_download_file(base, newname, 1, resume, 0,
+ NULL);
break;
case SMBC_FILE_SHARE:
/* Return 1 on error, 0 on success. */
-static int smb_download_file(const char *base, const char *name, int recursive, int resume, char *outfile) {
+static int smb_download_file(const char *base, const char *name, int recursive,
+ int resume, int toplevel, char *outfile)
+{
int remotehandle, localhandle;
time_t start_time = time(NULL);
const char *newpath;
if(newpath)newpath++; else newpath = base;
} else newpath = name;
- if(newpath[0] == '/')newpath++;
+ if (!toplevel && (newpath[0] == '/')) {
+ newpath++;
+ }
/* Open local file according to the mode */
if(update) {
while ( (file = poptGetArg(pc)) ) {
if (!recursive)
- ret = smb_download_file(file, "", recursive, resume, outputfile);
+ ret = smb_download_file(file, "", recursive, resume,
+ 1, outputfile);
else
ret = smb_download_dir(file, "", resume);
}