cleanup of unnecessarily convoluted function call
[rocksndiamonds.git] / src / libgame / zip / ioapi.c
index 5d9c10bd6ee04c3904ea70cd72116869756498ce..5a31fcbfdfb6ae598eed85bfe6c9ec6891baf21d 100644 (file)
@@ -45,11 +45,11 @@ long call_zseek64(const zlib_filefunc64_32_def *pfilefunc, voidpf filestream, ui
 {
     uint32_t offset_truncated = 0;
     if (pfilefunc->zfile_func64.zseek64_file != NULL)
-        return (*(pfilefunc->zfile_func64.zseek64_file)) (pfilefunc->zfile_func64.opaque,filestream,offset,origin);
+        return (*(pfilefunc->zfile_func64.zseek64_file)) (pfilefunc->zfile_func64.opaque, filestream, offset, origin);
     offset_truncated = (uint32_t)offset;
     if (offset_truncated != offset)
         return -1;
-    return (*(pfilefunc->zseek32_file))(pfilefunc->zfile_func64.opaque,filestream, offset_truncated, origin);
+    return (*(pfilefunc->zseek32_file))(pfilefunc->zfile_func64.opaque, filestream, offset_truncated, origin);
 }
 
 uint64_t call_ztell64(const zlib_filefunc64_32_def *pfilefunc, voidpf filestream)
@@ -121,7 +121,11 @@ static voidpf ZCALLBACK fopen64_file_func(ZIP_UNUSED voidpf opaque, const void *
 
     if ((filename != NULL) && (mode_fopen != NULL))
     {
-        file = fopen64((const char*)filename, mode_fopen);
+        const char *fd_prefix = "fd:";
+        if (strncmp(filename, fd_prefix, strlen(fd_prefix)) == 0)
+            file = fdopen(dup(atoi(&((const char*)filename)[strlen(fd_prefix)])), mode_fopen);
+        else
+            file = fopen64((const char*)filename, mode_fopen);
         return file_build_ioposix(file, (const char*)filename);
     }
     return file;