archivers/dir.c
changeset 22 49f6101707b4
parent 21 b1ea58d70a56
child 23 bd6ba9c8717c
equal deleted inserted replaced
21:b1ea58d70a56 22:49f6101707b4
    12 #include <errno.h>
    12 #include <errno.h>
    13 #include <sys/stat.h>
    13 #include <sys/stat.h>
    14 #include <sys/types.h>
    14 #include <sys/types.h>
    15 #include <fcntl.h>
    15 #include <fcntl.h>
    16 #include <unistd.h>
    16 #include <unistd.h>
       
    17 #include "physfs.h"
    17 
    18 
    18 #define __PHYSICSFS_INTERNAL__
    19 #define __PHYSICSFS_INTERNAL__
    19 #include "physfs_internal.h"
    20 #include "physfs_internal.h"
    20 
    21 
    21 extern const DirFunctions __PHYSFS_DirFunctions_DIR;
    22 extern const DirFunctions __PHYSFS_DirFunctions_DIR;
    28     FILE *h = (FILE *) (handle->opaque);
    29     FILE *h = (FILE *) (handle->opaque);
    29     int retval;
    30     int retval;
    30 
    31 
    31     errno = 0;
    32     errno = 0;
    32     retval = fread(buffer, objSize, objCount, h);
    33     retval = fread(buffer, objSize, objCount, h);
    33     if ( (retval < objCount) && (ferror(h)) )
    34     BAIL_IF_MACRO((retval < objCount) && (ferror(h)),strerror(errno),retval);
    34         __PHYSFS_setError(strerror(errno));
       
    35 
    35 
    36     return(retval);
    36     return(retval);
    37 } /* DIR_read */
    37 } /* DIR_read */
    38 
    38 
    39 
    39 
   292     NULL,           /* read() method      */
   292     NULL,           /* read() method      */
   293     DIR_write,      /* write() method     */
   293     DIR_write,      /* write() method     */
   294     DIR_eof,        /* eof() method       */
   294     DIR_eof,        /* eof() method       */
   295     DIR_tell,       /* tell() method      */
   295     DIR_tell,       /* tell() method      */
   296     DIR_seek,       /* seek() method      */
   296     DIR_seek,       /* seek() method      */
   297     DIR_fileClose,  /* fileClose() method */
   297     DIR_fileClose   /* fileClose() method */
   298 };
   298 };
   299 
   299 
   300 
   300 
   301 const DirFunctions __PHYSFS_DirFunctions_DIR =
   301 const DirFunctions __PHYSFS_DirFunctions_DIR =
   302 {
   302 {
   309     DIR_openRead,           /* openRead() method       */
   309     DIR_openRead,           /* openRead() method       */
   310     DIR_openWrite,          /* openWrite() method      */
   310     DIR_openWrite,          /* openWrite() method      */
   311     DIR_openAppend,         /* openAppend() method     */
   311     DIR_openAppend,         /* openAppend() method     */
   312     DIR_remove,             /* remove() method         */
   312     DIR_remove,             /* remove() method         */
   313     DIR_mkdir,              /* mkdir() method          */
   313     DIR_mkdir,              /* mkdir() method          */
   314     DIR_dirClose,           /* dirClose() method       */
   314     DIR_dirClose            /* dirClose() method       */
   315 };
   315 };
   316 
   316 
   317 
   317 
   318 /* This doesn't get listed, since it's technically not an archive... */
   318 /* This doesn't get listed, since it's technically not an archive... */
   319 #if 0
   319 #if 0
   320 const __PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_DIR =
   320 const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_DIR =
   321 {
   321 {
   322     "DIR",
   322     "DIR",
   323     "non-archive directory I/O"
   323     "non-archive directory I/O"
   324 };
   324 };
   325 #endif
   325 #endif