From: Greg Beaver Date: Mon, 11 Feb 2008 06:53:56 +0000 (+0000) Subject: move creation of phar archive to the point at which it is committed to disk, instead of X-Git-Tag: RELEASE_2_0_0a1~539 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d388ec586fd7f25fd341ac80914324f656686261;p=php move creation of phar archive to the point at which it is committed to disk, instead of at the moment it is attempted access. (making some real progress now, all tests pass on unix) --- diff --git a/ext/phar/phar.c b/ext/phar/phar.c index 90f1a0ca84..0e63965396 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -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) { diff --git a/ext/phar/util.c b/ext/phar/util.c index af3f3b78b6..af9abaf14a 100644 --- a/ext/phar/util.c +++ b/ext/phar/util.c @@ -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;