Tk Library Source Code

Artifact [d763636e02]
Login

Artifact d763636e0242d9cad710444a6187a1769b5b7194:

Attachment "503471.diff" to ticket [503471ffff] added by andreas_kupries 2002-01-15 12:45:52.
Index: ChangeLog
===================================================================
RCS file: /cvsroot/tcllib/tcllib/ChangeLog,v
retrieving revision 1.101
diff -u -r1.101 ChangeLog
--- ChangeLog	2002/01/12 00:35:44	1.101
+++ ChangeLog	2002/01/15 05:44:10
@@ -1,3 +1,7 @@
+2002-01-14  Andreas Kupries  <[email protected]>
+
+	* ftp: Fixed bug #503471.
+
 2002-01-11  Pat Thoyts  <[email protected]>
 
 	* mkInstallScripts.tcl:
Index: modules/ftp/ChangeLog
===================================================================
RCS file: /cvsroot/tcllib/tcllib/modules/ftp/ChangeLog,v
retrieving revision 1.22
diff -u -r1.22 ChangeLog
--- modules/ftp/ChangeLog	2001/11/21 03:25:33	1.22
+++ modules/ftp/ChangeLog	2002/01/15 05:44:10
@@ -1,3 +1,14 @@
+2002-01-14  Andreas Kupries <[email protected]>
+
+	* ftp.tcl: Fix for bug #503471. The commands Get, Reget, and Newer
+	  now check if the directory the local file is to be placed in
+	  does exist. They now immediately throw an error if the directory
+	  does not exist instead of starting the download and getting
+	  confused.
+
+	* ftp.n: Typo fix. Updates in the descriptions of Get, Reget, and
+	  Newer explaining the new behaviour, s.a.
+
 2001-11-20  Joe English <[email protected]>
 	* ftp.n: (r1.6 -> r1.8) Update for bug report #474999 
 	  "ftp man page description typo" -- attempt to clarify
Index: modules/ftp/ftp.n
===================================================================
RCS file: /cvsroot/tcllib/tcllib/modules/ftp/ftp.n,v
retrieving revision 1.8
diff -u -r1.8 ftp.n
--- modules/ftp/ftp.n	2001/11/21 03:25:33	1.8
+++ modules/ftp/ftp.n	2002/01/15 05:44:11
@@ -290,11 +290,13 @@
 \fBftp::Get\fR \fIhandle\fR \fIremote\fR ?(\fIlocal\fR | -variable \fIvarname\fR | -channel \fIchan\fR)?
 This command retrieves a remote file \fIremote\fR on the ftp server
 and stores its contents into the local file \fIlocal\fR. If the file
-parameters passed to the command do not fully qualified path names the
+parameters passed to the command are not fully qualified path names the
 command will use the current directory on local and remote host. If
 the local file name is unspecified, the server will use the name of
 the remote file as the name of the local file. The command returns 1
-to indicate a sucessful transfer and 0 in the case of a failure.
+to indicate a sucessful transfer and 0 in the case of a failure. The
+command will throw an error if the directory the file \fIlocal\fR is
+to be placed in does not exist.
 .sp
 If \fB-variable \fIvarname\fR is specified, the system will
 store the retrieved data into the variable \fIvarname\fR instead of a
@@ -310,8 +312,10 @@
 \fIlocal\fR exists and is smaller than remote file \fIremote\fR, the
 local file is presumed to be a partially transferred copy of the
 remote file and the transfer is continued from the apparent point of
-failure. This command is useful when transferring very large files
-over networks that tend to drop connections.
+failure.  The command will throw an error if the directory the file
+\fIlocal\fR is to be placed in does not exist. This command is useful
+when transferring very large files over networks that tend to drop
+connections.
 .sp
 Specifying the additional byte offsets \fIfrom\fR and \fIto\fR will
 cause the command to change its behaviour and to download exactly the
@@ -320,10 +324,12 @@
 to downloading till the end of the file.
 .TP
 \fBftp::Newer\fR \fIhandle\fR \fIremote\fR ?\fIlocal\fR?
-This command behaves like \fBftp::Get\fR, except that it retrives the
+This command behaves like \fBftp::Get\fR, except that it retrieves the
 remote file only if the modification time of the remote file is more
 recent than the file on the local system. If the file does not exist
-on the local system, the remote file is considered newer.
+on the local system, the remote file is considered newer. The command
+will throw an error if the directory the file \fIlocal\fR is to be
+placed in does not exist.
 .TP
 \fBftp::MkDir\fR \fIhandle\fR \fIdirectory\fR
 This command creates the specified \fIdirectory\fR on the ftp
Index: modules/ftp/ftp.tcl
===================================================================
RCS file: /cvsroot/tcllib/tcllib/modules/ftp/ftp.tcl,v
retrieving revision 1.21
diff -u -r1.21 ftp.tcl
--- modules/ftp/ftp.tcl	2001/11/19 21:02:19	1.21
+++ modules/ftp/ftp.tcl	2002/01/15 05:44:11
@@ -1960,6 +1960,9 @@
 		set dest [file join $dest [file tail $source]]
 	    }
 	}
+	if {![file exists [file dirname $dest]]} {
+	    return -code error "ftp::Get, directory \"[file dirname $dest]\" for destination \"$dest\" does not exist"
+	}
 	set ftp(LocalFilename) $dest
     }
 
@@ -2031,6 +2034,9 @@
     if { $dest == "" } {
         set dest $source
     }
+    if {![file exists [file dirname $dest]]} {
+	return -code error "ftp::Reget, directory \"[file dirname $dest]\" for destination \"$dest\" does not exist"
+    }
 
     set ftp(RemoteFilename) $source
     set ftp(LocalFilename) $dest
@@ -2117,6 +2123,9 @@
 
     if { $dest == "" } {
         set dest $source
+    }
+    if {![file exists [file dirname $dest]]} {
+	return -code error "ftp::Newer, directory \"[file dirname $dest]\" for destination \"$dest\" does not exist"
     }
 
     set ftp(RemoteFilename) $source