pollita         Fri Sep 22 20:02:26 2006 UTC

  Modified files:              
    /php-src/ext/standard       file.c 
  Log:
  Update copy() for PHP6
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.452&r2=1.453&diff_format=u
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.452 php-src/ext/standard/file.c:1.453
--- php-src/ext/standard/file.c:1.452   Fri Sep 22 18:23:33 2006
+++ php-src/ext/standard/file.c Fri Sep 22 20:02:26 2006
@@ -21,7 +21,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: file.c,v 1.452 2006/09/22 18:23:33 pollita Exp $ */
+/* $Id: file.c,v 1.453 2006/09/22 20:02:26 pollita Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -1779,23 +1779,45 @@
    Copy a file */
 PHP_FUNCTION(copy)
 {
-       zval **source, **target;
+       char *source, *dest;
+       int source_len, dest_len;
+       zend_uchar source_type, dest_type;
+       zend_uchar free_source = 0, free_dest = 0;
 
-       if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &source, &target) 
== FAILURE) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "tt", &source, 
&source_len, &source_type, &dest, &dest_len, &dest_type) == FAILURE) {
+               return;
        }
 
-       convert_to_string_ex(source);
-       convert_to_string_ex(target);
+       /* Assume failure until success is known */
+       RETVAL_FALSE;   
 
-       if (php_check_open_basedir(Z_STRVAL_PP(source) TSRMLS_CC)) {
-               RETURN_FALSE;
+       if (source_type == IS_UNICODE) {
+               if (FAILURE == php_stream_path_encode(NULL, &source, 
&source_len, (UChar*)source, source_len, REPORT_ERRORS, FG(default_context))) {
+                       goto copy_cleanup;
+               }
+               free_source = 1;
+       }
+       if (dest_type == IS_UNICODE) {
+               if (FAILURE == php_stream_path_encode(NULL, &dest, &dest_len, 
(UChar*)dest, dest_len, REPORT_ERRORS, FG(default_context))) {
+                       goto copy_cleanup;
+               }
+               free_dest = 1;
        }
 
-       if (php_copy_file(Z_STRVAL_PP(source), Z_STRVAL_PP(target) 
TSRMLS_CC)==SUCCESS) {
-               RETURN_TRUE;
-       } else {
-               RETURN_FALSE;
+       if (php_check_open_basedir(source TSRMLS_CC)) {
+               goto copy_cleanup;
+       }
+
+       if (php_copy_file(source, target TSRMLS_CC) == SUCCESS) {
+               RETVAL_TRUE;
+       }
+
+copy_cleanup:
+       if (free_source) {
+               efree(source);
+       }
+       if (free_dest) {
+               efree(dest);
        }
 }
 /* }}} */

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to