Skip to content

Commit

Permalink
-use php_stream_make_seekable
Browse files Browse the repository at this point in the history
  • Loading branch information
helly25 committed Mar 18, 2002
1 parent 318dc3e commit c645bab
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions ext/exif/exif.c
Original file line number Diff line number Diff line change
Expand Up @@ -2974,24 +2974,30 @@ int exif_read_file(image_info_type *ImageInfo, char *FileName, int read_thumbnai
ImageInfo->read_all = read_all;
ImageInfo->Thumbnail.filetype = IMAGE_FILETYPE_UNKNOWN;

/* Store file date/time. */
if (VCWD_STAT(FileName, &st) >= 0) {
ImageInfo->FileDateTime = st.st_mtime;
ImageInfo->FileSize = st.st_size;
#ifdef HAVE_PHP_STREAM
if ( php_stream_is(ImageInfo->infile, PHP_STREAM_IS_STDIO)) {
#endif
if (VCWD_STAT(FileName, &st) >= 0) {
/* Store file date/time. */
ImageInfo->FileDateTime = st.st_mtime;
ImageInfo->FileSize = st.st_size;
}
#ifdef HAVE_PHP_STREAM
} else {
ImageInfo->FileDateTime = 0;
#ifdef HAVE_PHP_STREAM
if ( !php_stream_is(ImageInfo->infile, PHP_STREAM_IS_STDIO)) {
mem_stream = php_memory_stream_create();
/* mem_stream = php_stream_fopen_tmpfile(); files my be big */
ImageInfo->FileSize = php_stream_copy_to_stream(ImageInfo->infile, mem_stream, PHP_STREAM_COPY_ALL);
auto_fclose(ImageInfo->infile);
ImageInfo->infile = mem_stream;
/*
mem_stream = php_stream_temp_create(TEMP_STREAM_DEFAULT,20000000);
ImageInfo->FileSize = php_stream_copy_to_stream(ImageInfo->infile, mem_stream, PHP_STREAM_COPY_ALL);
auto_fclose(ImageInfo->infile);
*/
php_stream_make_seekable( ImageInfo->infile, &mem_stream);
if ( !ImageInfo->FileSize) {
php_stream_seek(mem_stream,0,SEEK_END);
ImageInfo->FileSize = php_stream_tell(mem_stream);
php_stream_seek(mem_stream,0,SEEK_SET);
}
#else
ImageInfo->FileSize = 0;
#endif
ImageInfo->infile = mem_stream;
}
#endif

/* Scan the JPEG headers. */
ret = exif_scan_FILE_header(ImageInfo);
Expand Down

0 comments on commit c645bab

Please sign in to comment.