A program to extrac files from .viv files (NFS 3-4)
Raul Fernandes <[email protected]>
| Newsgroups | gmane.games.torcs.devel |
|---|---|
| Message-ID | <[email protected]> |
Thanks for this great game. I have played it a lot. After read the "How-to import NFS cars" I have difficulties to convert the cars because I only use linux and NFSWizard only runs in windows. I have to install the vmware and run windows inside it. Weird solution. Another problem is that NFSWizard only runs in win98. Running in compatibility mode in winxp is buggy. I have read that the author lost the sourcecode (?) and cannot update the program. As NFSWizard is only used to extract file from viv file I have the idea to look into viv file to try to understand the format. I have found that viv file format is very simple. So I have made a program that extract the files to replace the NFSWizard. It compiles and runs in linux, but should can compiles and runs in windows too as it is very simple. To compile: gcc -o extractviv extractviv.c I want to contribute the program to TORCS. The sourcecode is under GPL too. Please put it in official package and update the howto. The other users will thanks for it. Regards Raul Fernandes [email protected] Abra sua conta no Yahoo! Mail, o único sem limite de espaço para armazenamento! http://br.mail.yahoo.com/ ------------------------------------------------------------------------- SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future. http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 _______________________________________________ Torcs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/torcs-devel
extractviv.c
(application/octet-stream, 3.8 KB)
/*************************************************************************** * Copyright (C) 2007 by Raul Fernandes * * [email protected] * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ // This program extract all files in a viv file to current directory #include <stdio.h> #include <stdlib.h> void usage( const char *programname ) { printf( "Usage:\n" ); printf( "%s file.viv\n", programname ); printf( "\n" ); printf( "Extract all files in file.viv to current directory.\n" ); printf( "\n" ); } int readInt32( FILE *file ) { int data; data = fgetc( file ); data = data << 8 | fgetc( file ); data = data << 8 | fgetc( file ); data = data << 8 | fgetc( file ); return data; } int main( int argc, char **argv ) { if( argc < 2 ) { usage( argv[0] ); exit( 1 ); } FILE *vivfile, *outfile; // file stream char *vivfilename = argv[1]; // viv filename int numberOfFiles; // number of files in viv file char filename[100]; int filepos, filesize; char buf[4]; char c; int pos; long currentpos; int a, b; vivfile = fopen( vivfilename, "r" ); if( !vivfile ) { printf( "Error while opening %s\n", vivfilename ); exit( 2 ); } for( a = 0; a < 4; a++ ) { buf[a] = fgetc( vivfile ); } if( memcmp( buf, "BIGF", 4 ) ) { printf( "%s if not a viv file\n", vivfilename ); fclose( vivfile ); exit( 3 ); } readInt32( vivfile ); // size of viv file numberOfFiles = readInt32( vivfile ); printf( "Number of files: %d\n", numberOfFiles ); readInt32( vivfile ); // start position of files currentpos = ftell( vivfile ); for( a = 0; a < numberOfFiles; a++ ) { if( fseek( vivfile, currentpos, SEEK_SET ) ) { printf( "Error while seeking in file %s\n", vivfilename ); fclose( vivfile ); exit( 4 ); } filepos = readInt32( vivfile ); filesize = readInt32( vivfile ); pos = 0; c = fgetc( vivfile ); while( c != '\0' ) { filename[pos] = c; pos++; c = fgetc( vivfile ); } filename[pos] = '\0'; currentpos = ftell( vivfile ); if( (outfile = fopen( filename, "w" )) == NULL ) { printf( "Error while opening file %s\n", filename ); fclose( vivfile ); exit( 4 ); } if( fseek( vivfile, filepos, SEEK_SET ) ) { printf( "Error while seeking in file %s\n", vivfilename ); fclose( vivfile ); exit( 3 ); } for( b = 0; b < filesize; b++ ) { c = fgetc( vivfile ); fputc( c, outfile ); } fclose( outfile ); printf( "File %s written successfully\n", filename ); } fclose( vivfile ); }