archivers/dir.c
changeset 132 b53fa5093749
parent 126 f5135b499c0c
child 135 57ba3130b1e7
equal deleted inserted replaced
131:69b093825303 132:b53fa5093749
    14 #include "physfs.h"
    14 #include "physfs.h"
    15 
    15 
    16 #define __PHYSICSFS_INTERNAL__
    16 #define __PHYSICSFS_INTERNAL__
    17 #include "physfs_internal.h"
    17 #include "physfs_internal.h"
    18 
    18 
    19 static int DIR_read(FileHandle *handle, void *buffer,
    19 static PHYSFS_sint64 DIR_read(FileHandle *handle, void *buffer,
    20                     unsigned int objSize, unsigned int objCount);
    20                               PHYSFS_uint32 objSize, PHYSFS_uint32 objCount);
    21 static int DIR_write(FileHandle *handle, const void *buffer,
    21 static PHYSFS_sint64 DIR_write(FileHandle *handle, const void *buffer,
    22                      unsigned int objSize, unsigned int objCount);
    22                                PHYSFS_uint32 objSize, PHYSFS_uint32 objCount);
    23 static int DIR_eof(FileHandle *handle);
    23 static int DIR_eof(FileHandle *handle);
    24 static int DIR_tell(FileHandle *handle);
    24 static PHYSFS_sint64 DIR_tell(FileHandle *handle);
    25 static int DIR_seek(FileHandle *handle, int offset);
    25 static int DIR_seek(FileHandle *handle, PHYSFS_uint64 offset);
    26 static int DIR_fileLength(FileHandle *handle);
    26 static PHYSFS_sint64 DIR_fileLength(FileHandle *handle);
    27 static int DIR_fileClose(FileHandle *handle);
    27 static int DIR_fileClose(FileHandle *handle);
    28 static int DIR_isArchive(const char *filename, int forWriting);
    28 static int DIR_isArchive(const char *filename, int forWriting);
    29 static DirHandle *DIR_openArchive(const char *name, int forWriting);
    29 static DirHandle *DIR_openArchive(const char *name, int forWriting);
    30 static LinkedStringList *DIR_enumerateFiles(DirHandle *h,
    30 static LinkedStringList *DIR_enumerateFiles(DirHandle *h,
    31                                             const char *dname,
    31                                             const char *dname,
    92     "http://www.icculus.org/physfs/",
    92     "http://www.icculus.org/physfs/",
    93 };
    93 };
    94 #endif
    94 #endif
    95 
    95 
    96 
    96 
    97 static int DIR_read(FileHandle *handle, void *buffer,
    97 static PHYSFS_sint64 DIR_read(FileHandle *handle, void *buffer,
    98                     unsigned int objSize, unsigned int objCount)
    98                               PHYSFS_uint32 objSize, PHYSFS_uint32 objCount)
    99 {
    99 {
   100     FILE *h = (FILE *) (handle->opaque);
   100     FILE *h = (FILE *) (handle->opaque);
   101     size_t retval;
   101     size_t retval;
   102 
   102 
   103     errno = 0;
   103     errno = 0;
   107 
   107 
   108     return((int) retval);
   108     return((int) retval);
   109 } /* DIR_read */
   109 } /* DIR_read */
   110 
   110 
   111 
   111 
   112 static int DIR_write(FileHandle *handle, const void *buffer,
   112 static PHYSFS_sint64 DIR_write(FileHandle *handle, const void *buffer,
   113                      unsigned int objSize, unsigned int objCount)
   113                                PHYSFS_uint32 objSize, PHYSFS_uint32 objCount)
   114 {
   114 {
   115     FILE *h = (FILE *) (handle->opaque);
   115     FILE *h = (FILE *) (handle->opaque);
   116     size_t retval;
   116     size_t retval;
   117 
   117 
   118     errno = 0;
   118     errno = 0;
   128 {
   128 {
   129     return(feof((FILE *) (handle->opaque)));
   129     return(feof((FILE *) (handle->opaque)));
   130 } /* DIR_eof */
   130 } /* DIR_eof */
   131 
   131 
   132 
   132 
   133 static int DIR_tell(FileHandle *handle)
   133 static PHYSFS_sint64 DIR_tell(FileHandle *handle)
   134 {
   134 {
   135     return(ftell((FILE *) (handle->opaque)));
   135     return(ftell((FILE *) (handle->opaque)));
   136 } /* DIR_tell */
   136 } /* DIR_tell */
   137 
   137 
   138 
   138 
   139 static int DIR_seek(FileHandle *handle, int offset)
   139 static int DIR_seek(FileHandle *handle, PHYSFS_uint64 offset)
   140 {
   140 {
   141     return(fseek((FILE *) (handle->opaque), offset, SEEK_SET) == 0);
   141     return(fseek((FILE *) (handle->opaque), offset, SEEK_SET) == 0);
   142 } /* DIR_seek */
   142 } /* DIR_seek */
   143 
   143 
   144 
   144 
   145 static int DIR_fileLength(FileHandle *handle)
   145 static PHYSFS_sint64 DIR_fileLength(FileHandle *handle)
   146 {
   146 {
   147     return(__PHYSFS_platformFileLength((FILE *) (handle->opaque)));
   147     return(__PHYSFS_platformFileLength((FILE *) (handle->opaque)));
   148 } /* DIR_fileLength */
   148 } /* DIR_fileLength */
   149 
   149 
   150 
   150