]> granicus.if.org Git - php/commitdiff
-use php_stream_make_seekable
authorMarcus Boerger <helly@php.net>
Mon, 18 Mar 2002 00:12:47 +0000 (00:12 +0000)
committerMarcus Boerger <helly@php.net>
Mon, 18 Mar 2002 00:12:47 +0000 (00:12 +0000)
ext/exif/exif.c

index 5cb796ee6cb290e5c5b86fa97d89b3dcb6abe1c6..b0ecc631cc8637385c5f773754e7a2eaa39b9b74 100644 (file)
@@ -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);