aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2003-01-07 11:25:44 +0000
committerDaniel Stenberg <daniel@haxx.se>2003-01-07 11:25:44 +0000
commit37ae32f6888f8cd3212eff5fd1cb46f34d5f2269 (patch)
tree8408d9b85743ea10a80a93a2a96b09f90b3abca8
parentd0cffdec5dcc1aadf1c1582440d0046e35ab10dc (diff)
Only output valid filetime.
Return file-error if 550 is returned when trying MDTM
-rw-r--r--lib/ftp.c40
1 files changed, 24 insertions, 16 deletions
diff --git a/lib/ftp.c b/lib/ftp.c
index 121b3de49..97956af97 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -756,22 +756,30 @@ CURLcode ftp_getfiletime(struct connectdata *conn, char *file)
if(result)
return result;
- if(ftpcode == 213) {
- /* we got a time. Format should be: "YYYYMMDDHHMMSS[.sss]" where the
- last .sss part is optional and means fractions of a second */
- int year, month, day, hour, minute, second;
- if(6 == sscanf(buf+4, "%04d%02d%02d%02d%02d%02d",
- &year, &month, &day, &hour, &minute, &second)) {
- /* we have a time, reformat it */
- time_t secs=time(NULL);
- sprintf(buf, "%04d%02d%02d %02d:%02d:%02d",
- year, month, day, hour, minute, second);
- /* now, convert this into a time() value: */
- conn->data->info.filetime = curl_getdate(buf, &secs);
- }
- else {
- infof(conn->data, "unsupported MDTM reply format\n");
+ switch(ftpcode) {
+ case 213:
+ {
+ /* we got a time. Format should be: "YYYYMMDDHHMMSS[.sss]" where the
+ last .sss part is optional and means fractions of a second */
+ int year, month, day, hour, minute, second;
+ if(6 == sscanf(buf+4, "%04d%02d%02d%02d%02d%02d",
+ &year, &month, &day, &hour, &minute, &second)) {
+ /* we have a time, reformat it */
+ time_t secs=time(NULL);
+ sprintf(buf, "%04d%02d%02d %02d:%02d:%02d",
+ year, month, day, hour, minute, second);
+ /* now, convert this into a time() value: */
+ conn->data->info.filetime = curl_getdate(buf, &secs);
+ }
}
+ break;
+ default:
+ infof(conn->data, "unsupported MDTM reply format\n");
+ break;
+ case 550: /* "No such file or directory" */
+ failf(conn->data, "Given file does not exist");
+ result = CURLE_FTP_COULDNT_RETR_FILE;
+ break;
}
return result;
}
@@ -1989,7 +1997,7 @@ CURLcode ftp_perform(struct connectdata *conn,
well, we "emulate" a HTTP-style header in our output. */
#ifdef HAVE_STRFTIME
- if(data->set.get_filetime && data->info.filetime) {
+ if(data->set.get_filetime && (data->info.filetime>=0) ) {
struct tm *tm;
#ifdef HAVE_LOCALTIME_R
struct tm buffer;