]> granicus.if.org Git - php/commitdiff
move creation of phar archive to the point at which it is committed to disk, instead of
authorGreg Beaver <cellog@php.net>
Mon, 11 Feb 2008 06:53:56 +0000 (06:53 +0000)
committerGreg Beaver <cellog@php.net>
Mon, 11 Feb 2008 06:53:56 +0000 (06:53 +0000)
at the moment it is attempted access. (making some real progress now, all tests pass on unix)

ext/phar/phar.c
ext/phar/util.c

index 90f1a0ca847afe01803968581b8b5afd1fb4988b..0e639653966bae86122dfe5e55fca793c5d5f839 100644 (file)
@@ -1038,28 +1038,11 @@ int phar_create_or_parse_filename(char *fname, int fname_len, char *alias, int a
        /* set up our manifest */
        mydata = ecalloc(sizeof(phar_archive_data), 1);
 
-       /* re-open for writing (we only reach here if the file does not exist) */
-       fp = php_stream_open_wrapper(fname, "w+b", IGNORE_URL|STREAM_MUST_SEEK|0, &mydata->fname);
-       if (!fp) {
-               if (options & REPORT_ERRORS) {
-                       if (error) {
-                               spprintf(error, 0, "creating archive \"%s\" failed", fname);
-                       }
-               }
-               return FAILURE;
-       }
-       if (mydata->fname) {
-               fname = mydata->fname;
-#ifdef PHP_WIN32
-               phar_unixify_path_separators(fname, fname_len);
-#endif
-               fname_len = strlen(mydata->fname);
-       } else {
-               mydata->fname = estrndup(fname, fname_len);
+       mydata->fname = expand_filepath(fname, NULL TSRMLS_CC);
 #ifdef PHP_WIN32
-               phar_unixify_path_separators(mydata->fname, fname_len);
+       phar_unixify_path_separators(fname, fname_len);
 #endif
-       }
+       fname_len = strlen(mydata->fname);
        
        if (pphar) {
                *pphar = mydata;
@@ -1072,7 +1055,7 @@ int phar_create_or_parse_filename(char *fname, int fname_len, char *alias, int a
        snprintf(mydata->version, sizeof(mydata->version), "%s", PHAR_API_VERSION_STR);
        mydata->is_temporary_alias = alias ? 0 : 1;
        mydata->internal_file_start = -1;
-       mydata->fp = fp;
+       mydata->fp = NULL;
        mydata->is_writeable = 1;
        mydata->is_brandnew = 1;
        if (!alias_len || !alias) {
index af3f3b78b6046e1fee036e65919617599b40f8c5..af9abaf14add9140c167c61c0c09cc3275f7926c 100644 (file)
@@ -39,6 +39,9 @@ int phar_seek_efp(phar_entry_info *entry, off_t offset, int whence, off_t positi
        php_stream *fp = phar_get_efp(entry);
        off_t temp;
 
+       if (entry->is_dir) {
+               return 0;
+       }
        switch (whence) {
                case SEEK_END :
                        temp = entry->offset + entry->uncompressed_filesize + offset;