]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - tools/quake3/common/vfs.c
Merge commit '020d0244e4239b21dc804d630edff926386ea34f' into master-merge
[xonotic/netradiant.git] / tools / quake3 / common / vfs.c
index 345846e67045436c0a7a45acae85fe0df3b8aa1c..b4f38690c2d5a517cb5f0807ef69e83f15c4612e 100644 (file)
@@ -678,3 +678,45 @@ qboolean vfsPackFile( const char *filename, const char *packname, const int comp
                Error( "Disabled because of miniz issue" );
 #endif
 }
+
+qboolean vfsPackFile_Absolute_Path( const char *filepath, const char *filename, const char *packname, const int compLevel ){
+#ifndef GARUX_DISABLE_BAD_MINIZ
+       char tmp[NAME_MAX];
+       strcpy( tmp, filepath );
+       if ( access( tmp, R_OK ) == 0 ) {
+               if ( access( packname, R_OK ) == 0 ) {
+                       mz_zip_archive zip;
+                       memset( &zip, 0, sizeof(zip) );
+                       mz_zip_reader_init_file( &zip, packname, 0 );
+                       mz_zip_writer_init_from_reader( &zip, packname );
+
+                       mz_bool success = MZ_TRUE;
+                       success &= mz_zip_writer_add_file( &zip, filename, tmp, 0, 0, compLevel );
+                       if ( !success || !mz_zip_writer_finalize_archive( &zip ) ){
+                               Error( "Failed creating zip archive \"%s\"!\n", packname );
+                       }
+                       mz_zip_reader_end( &zip);
+                       mz_zip_writer_end( &zip );
+               }
+               else{
+                       mz_zip_archive zip;
+                       memset( &zip, 0, sizeof(zip) );
+                       if( !mz_zip_writer_init_file( &zip, packname, 0 ) ){
+                               Error( "Failed creating zip archive \"%s\"!\n", packname );
+                       }
+                       mz_bool success = MZ_TRUE;
+                       success &= mz_zip_writer_add_file( &zip, filename, tmp, 0, 0, compLevel );
+                       if ( !success || !mz_zip_writer_finalize_archive( &zip ) ){
+                               Error( "Failed creating zip archive \"%s\"!\n", packname );
+                       }
+                       mz_zip_writer_end( &zip );
+               }
+
+               return qtrue;
+       }
+
+       return qfalse;
+#else
+               Error( "Disabled because of miniz issue" );
+#endif
+}