pollita Wed Jul 21 00:37:47 2004 EDT Modified files: /php-src/ext/standard ftp_fopen_wrapper.c Log: Add MTDM support to ftp_fopen_wrapper::url_stat() http://cvs.php.net/diff.php/php-src/ext/standard/ftp_fopen_wrapper.c?r1=1.74&r2=1.75&ty=u Index: php-src/ext/standard/ftp_fopen_wrapper.c diff -u php-src/ext/standard/ftp_fopen_wrapper.c:1.74 php-src/ext/standard/ftp_fopen_wrapper.c:1.75 --- php-src/ext/standard/ftp_fopen_wrapper.c:1.74 Mon May 17 16:31:59 2004 +++ php-src/ext/standard/ftp_fopen_wrapper.c Wed Jul 21 00:37:47 2004 @@ -18,7 +18,7 @@ | Sara Golemon <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ */ -/* $Id: ftp_fopen_wrapper.c,v 1.74 2004/05/17 20:31:59 pollita Exp $ */ +/* $Id: ftp_fopen_wrapper.c,v 1.75 2004/07/21 04:37:47 pollita Exp $ */ #include "php.h" #include "php_globals.h" @@ -769,12 +769,58 @@ ssb->sb.st_size = atoi(tmp_line + 4); } + php_stream_write_string(stream, "MDTM "); + if (resource->path != NULL) { + php_stream_write_string(stream, resource->path); + } else { + php_stream_write_string(stream, "/"); + } + php_stream_write_string(stream, "\r\n"); + result = GET_FTP_RESULT(stream); + if (result == 213) { + char *p = tmp_line + 4; + int n; + struct tm tm, tmbuf, *gmt; + time_t stamp; + + while (p - tmp_line < sizeof(tmp_line) && !isdigit(*p)) { + p++; + } + + if (p - tmp_line > sizeof(tmp_line)) { + goto mdtm_error; + } + + n = sscanf(p, "%4u%2u%2u%2u%2u%2u", &tm.tm_year, &tm.tm_mon, &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec); + if (n != 6) { + goto mdtm_error; + } + + tm.tm_year -= 1900; + tm.tm_mon--; + tm.tm_isdst = -1; + + /* figure out the GMT offset */ + stamp = time(NULL); + gmt = php_gmtime_r(&stamp, &tmbuf); + gmt->tm_isdst = -1; + + /* apply the GMT offset */ + tm.tm_sec += stamp - mktime(gmt); + tm.tm_isdst = gmt->tm_isdst; + + ssb->sb.st_mtime = mktime(&tm); + } else { + /* error or unsupported command */ + mdtm_error: + ssb->sb.st_mtime = -1; + } + ssb->sb.st_ino = 0; /* Unknown values */ ssb->sb.st_dev = 0; ssb->sb.st_uid = 0; ssb->sb.st_gid = 0; ssb->sb.st_atime = -1; - ssb->sb.st_mtime = -1; ssb->sb.st_ctime = -1; ssb->sb.st_nlink = 1; ssb->sb.st_rdev = -1;
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php