misc/libphyslayer/physfsrwops.c
changeset 9378 2be457289e60
parent 9309 7e8f91634f80
child 10017 de822cd3df3a
equal deleted inserted replaced
9377:48ab6dea8d2f 9378:2be457289e60
    30 #define TARGET_SDL13 1
    30 #define TARGET_SDL13 1
    31 #endif
    31 #endif
    32 #endif
    32 #endif
    33 
    33 
    34 #if TARGET_SDL13
    34 #if TARGET_SDL13
       
    35 static SDLCALL Sint64 physfsrwops_size(struct SDL_RWops *rw)
       
    36 {
       
    37     PHYSFS_File *handle = (PHYSFS_File *) rw->hidden.unknown.data1;
       
    38     return PHYSFS_fileLength(handle);
       
    39 }
       
    40 #endif
       
    41 
       
    42 #if TARGET_SDL13
    35 static SDLCALL Sint64 physfsrwops_seek(struct SDL_RWops *rw, Sint64 offset, int whence)
    43 static SDLCALL Sint64 physfsrwops_seek(struct SDL_RWops *rw, Sint64 offset, int whence)
    36 #else
    44 #else
    37 static int physfsrwops_seek(SDL_RWops *rw, int offset, int whence)
    45 static int physfsrwops_seek(SDL_RWops *rw, int offset, int whence)
    38 #endif
    46 #endif
    39 {
    47 {
    40     PHYSFS_File *handle = (PHYSFS_File *) rw->hidden.unknown.data1;
    48     PHYSFS_File *handle = (PHYSFS_File *) rw->hidden.unknown.data1;
    41     PHYSFS_sint64 pos = 0;
    49     PHYSFS_sint64 pos = 0;
    42 
    50 
    43     if (whence == SEEK_SET)
    51     if (whence == SEEK_SET)
    44         pos = (PHYSFS_sint64) offset;
    52         pos = (PHYSFS_sint64) offset;
    45 
       
    46     else if (whence == SEEK_CUR)
    53     else if (whence == SEEK_CUR)
    47     {
    54     {
    48         const PHYSFS_sint64 current = PHYSFS_tell(handle);
    55         const PHYSFS_sint64 current = PHYSFS_tell(handle);
    49         if (current == -1)
    56         if (current == -1)
    50         {
    57         {
   171     else
   178     else
   172     {
   179     {
   173         retval = SDL_AllocRW();
   180         retval = SDL_AllocRW();
   174         if (retval != NULL)
   181         if (retval != NULL)
   175         {
   182         {
       
   183 #if TARGET_SDL13
       
   184             retval->size  = physfsrwops_size;
       
   185 #endif
   176             retval->seek  = physfsrwops_seek;
   186             retval->seek  = physfsrwops_seek;
   177             retval->read  = physfsrwops_read;
   187             retval->read  = physfsrwops_read;
   178             retval->write = physfsrwops_write;
   188             retval->write = physfsrwops_write;
   179             retval->close = physfsrwops_close;
   189             retval->close = physfsrwops_close;
   180             retval->hidden.unknown.data1 = handle;
   190             retval->hidden.unknown.data1 = handle;