]> granicus.if.org Git - php/commitdiff
Add resume_pos (resume position) context option for restarting file downloads.
authorSara Golemon <pollita@php.net>
Wed, 20 Aug 2003 21:59:29 +0000 (21:59 +0000)
committerSara Golemon <pollita@php.net>
Wed, 20 Aug 2003 21:59:29 +0000 (21:59 +0000)
ext/standard/ftp_fopen_wrapper.c

index 826bd9453be255db6559a6579dc0cd2b61ccde4a..b586bc8e16103b8141cad2b105be39a3fe100829 100644 (file)
@@ -472,6 +472,20 @@ php_stream * php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, char *path, ch
 
        /* Send RETR/STOR command */
        if (read_write == 1) {
+               /* set resume position if applicable */
+               if (context &&
+                       php_stream_context_get_option(context, "ftp", "resume_pos", &tmpzval) == SUCCESS &&
+                       Z_TYPE_PP(tmpzval) == IS_LONG &&
+                       Z_LVAL_PP(tmpzval) > 0) {
+                       snprintf(tmp_line, 511, "REST %u\r\n", Z_LVAL_PP(tmpzval));
+                       php_stream_write_string(stream, tmp_line);
+                       result = GET_FTP_RESULT(stream);
+                       if (result < 300 || result > 399) {                     
+                               php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Unable to resume from offset %d", Z_LVAL_PP(tmpzval));
+                               goto errexit;
+                       }
+               }
+
                /* retrieve file */
                php_stream_write_string(stream, "RETR ");
        } else if (read_write == 2) {