diff -Naur ncftp-3.0.2/libncftp/glob.c ncftp-3.0.2.fix/libncftp/glob.c --- ncftp-3.0.2/libncftp/glob.c Wed Oct 18 03:08:53 2000 +++ ncftp-3.0.2.fix/libncftp/glob.c Thu Feb 7 17:31:42 2002 @@ -1151,6 +1151,9 @@ fi.size = (longest_int) st->st_size; fi.type = 'd'; (void) AddFileInfo(filp, &fi); + } else { + /* Changed by Hindin - fix problem with -R . */ + strcpy(relpath,"."); } /* Handle directory entry first. */ @@ -1246,6 +1249,8 @@ nextFilePtr = filePtr->next; (void) STRNCPY(fullpath, filePtr->line); /* initialize fullpath */ + /* Changed by Hindin */ + StrRemoveTrailingLocalPathDelim(filePtr->line); if ((erelative != 0) || (strcmp(filePtr->line, ".") == 0) || (filePtr->line[0] == '\0')) (void) STRNCPY(relpath, ""); else if ((cp = StrRFindLocalPathDelim(filePtr->line)) == NULL) diff -Naur ncftp-3.0.2/sh_util/ncftpput.c ncftp-3.0.2.fix/sh_util/ncftpput.c --- ncftp-3.0.2/sh_util/ncftpput.c Wed Oct 18 00:26:39 2000 +++ ncftp-3.0.2.fix/sh_util/ncftpput.c Thu Feb 7 16:56:34 2002 @@ -84,7 +84,8 @@ -y Try using \"SITE UTIME\" to preserve timestamps on remote host.\n\ -B XX Try setting the SO_SNDBUF size to XX.\n\ -r XX Redial XX times until connected.\n\ - -R Recursive mode; copy whole directory trees.\n"); + -R Recursive mode; copy whole directory trees.\n\ + -l Get relative remote directory from argument" ); (void) fprintf(fp, "\nExamples:\n\ ncftpput -u gleason -p my.password Elwood.probe.net /home/gleason stuff.txt\n\ ncftpput -u gleason Elwood.probe.net /home/gleason a.txt (prompt for pass)\n\ @@ -123,20 +124,53 @@ +#ifndef WIN32 +#define _MAX_PATH 512 +#endif static int -Copy(FTPCIPtr cip, const char *const dstdir, char **const files, const int rflag, const int xtype, const int appendflag, const char *const tmppfx, const char *const tmpsfx, const int resumeflag, const int deleteflag) +Copy(FTPCIPtr cip, const char *const dstdir, char **const files, const int lflag,const int wantMkdir,const int rflag, const int xtype, const int appendflag, const char *const tmppfx, const char *const tmpsfx, const int resumeflag, const int deleteflag) { int i; int result; const char *file; int rc = 0; + char *dstfiledir=0; + char *currDir; + char *cp; + + if (dstdir != NULL) { + if (wantMkdir != 0) { + result = FTPChdir3(&fi, dstdir, NULL, 0, kChdirOneSubdirAtATime|kChdirAndMkdir); + } else { + result = FTPChdir3(&fi, dstdir, NULL, 0, kChdirOneSubdirAtATime); + } + } + if (result!=0) + return result; + + if (lflag) { + dstfiledir = (char *)malloc(_MAX_PATH); + currDir = (char *)malloc(_MAX_PATH); + FTPGetCWD(&fi,currDir,_MAX_PATH); + } else { + dstfiledir = ""; + } for (i=0; ; i++) { file = files[i]; if (file == NULL) break; - result = FTPPutFiles3(cip, file, dstdir, rflag, + if (lflag) { + strcpy(dstfiledir,file); + StrRemoveTrailingLocalPathDelim(dstfiledir); + cp = StrRFindLocalPathDelim(dstfiledir); + *cp = 0; + if (wantMkdir) { + result = FTPMkdir2(cip,dstfiledir,1,currDir); + } + } + result = FTPPutFiles3(cip, file, dstfiledir, rflag, #if defined(WIN32) || defined(_WINDOWS) kGlobYes, #else @@ -148,6 +182,11 @@ rc = result; } } + if (lflag) { + free(dstfiledir); + free(currDir); + } + return (rc); } /* Copy */ @@ -158,6 +197,7 @@ { int result, c; int rflag = 0; + int lflag = 0; int appendflag = kAppendNo; int deleteflag = kDeleteNo; int resumeflag = kResumeNo; @@ -213,7 +253,7 @@ (void) STRNCPY(fi.user, "anonymous"); progmeters = GetDefaultProgressMeterSetting(); - while ((c = getopt(argc, argv, "P:u:j:p:e:d:U:t:mar:RvVf:AT:S:EFcyZzDbB:")) > 0) switch(c) { + while ((c = getopt(argc, argv, "P:u:j:p:e:d:U:t:mar:RlvVf:AT:S:EFcyZzDbB:")) > 0) switch(c) { case 'P': fi.port = atoi(optarg); break; @@ -271,6 +311,9 @@ case 'R': rflag = 1; break; + case 'l': + lflag = 1; + break; case 'v': progmeters = 1; break; @@ -431,17 +474,6 @@ FTPPerror(&fi, result, kErrUmaskFailed, "ncftpput", "could not set umask"); } - if (dstdir != NULL) { - es = kExitChdirTimedOut; - if (wantMkdir != 0) { - errstr = "could not create and chdir on remote host"; - result = FTPChdir3(&fi, dstdir, NULL, 0, kChdirOneSubdirAtATime|kChdirAndMkdir); - } else { - errstr = "could not chdir on remote host"; - result = FTPChdir3(&fi, dstdir, NULL, 0, kChdirOneSubdirAtATime); - } - } - if (result != 0) { FTPPerror(&fi, result, kErrCWDFailed, "ncftpput: Could not change to directory", dstdir); (void) FTPCloseHost(&fi); @@ -455,10 +487,11 @@ es = kExitXferTimedOut; (void) signal(SIGINT, Abort); if (ftpcat == 0) { - if (Copy(&fi, "", files, rflag, xtype, appendflag, (const char *) tmppfx, (const char *) tmpsfx, resumeflag, deleteflag) < 0) + if (Copy(&fi, dstdir, files, lflag, wantMkdir, rflag, xtype, appendflag, (const char *) tmppfx, (const char *) tmpsfx, resumeflag, deleteflag) < 0) es = kExitXferFailed; else es = kExitSuccess; + } else { fi.progress = (FTPProgressMeterProc) 0; if (FTPPutOneFile2(&fi, NULL, argv[optind + 1], xtype, STDIN_FILENO, appendflag, tmppfx, tmpsfx) < 0)