23 #include <sys/types.h>
30 static int data_error;
35 #if BYTE_ORDER == BIG_ENDIAN
36 #define INT_SWAP(x) ( \
38 (((ulong)x) >> 24) | \
39 ((x & 0x0000ff00) << 8) | \
40 ((x & 0x00ff0000) >> 8) \
43 #define INT_SWAP(x) (x)
52 return fwrite(&tmp, 1,
sizeof(
int), stream);
72 #define BLOCK_SIZE (1024*1024)
73 #define VERSION_NUMBER 2;
81 fseek(
fp_out, 0, SEEK_SET);
82 fwrite(
"VPVP", 1, 4,
fp_out);
90 FILE *
h = NULL, *d = NULL;
96 if ( (h == NULL) || (d == NULL) )
122 if ( strstr( filename,
".vp" )) {
127 if ( strstr( filename,
".hdr" )) {
132 if ( filesize == 0 ) {
137 if ( strlen(filename) > 31 ) {
138 printf(
"Filename '%s' too long! Skipping...\n", filename );
142 memset( path, 0,
sizeof(path) );
158 FILE *
fp = fopen( path,
"rb" );
161 printf(
"Error opening '%s'\n", path );
165 int nbytes, nbytes_read=0;
171 nbytes_read += nbytes;
174 }
while( nbytes > 0 );
178 printf(
" %d bytes\n", nbytes_read );
185 char *pathptr =
path;
216 ts = filespec + (strlen(filespec) - 1);
225 printf(
"In dir '%s'\n", tmp1 );
228 find_handle = _findfirst( tmp1, &find );
229 if( find_handle != -1 ) {
230 if ( find.attrib & _A_SUBDIR ) {
231 if (strcmp(
"..", find.name) && strcmp(
".", find.name) && strcmp(
".svn", find.name)) {
234 strcat( tmp, find.name );
238 pack_file( filespec, find.name, find.size, find.time_write );
241 while( !_findnext( find_handle, &find ) ) {
242 if ( find.attrib & _A_SUBDIR ) {
243 if (strcmp(
"..", find.name) && strcmp(
".", find.name) && strcmp(
".svn", find.name)) {
246 strcat( tmp, find.name );
251 pack_file( filespec, find.name, find.size, find.time_write );
259 dirp = opendir (filespec);
261 while ((dir = readdir(dirp)) != NULL) {
264 snprintf(fn,
MAX_PATH-1,
"%s/%s", filespec, dir->d_name);
268 if (stat(fn, &buf) == -1) {
272 if ( (strcmp(dir->d_name,
".") == 0) || (strcmp(dir->d_name,
"..") == 0) ) {
276 if ( (strcmp(dir->d_name,
".svn") == 0) ) {
280 if (S_ISDIR(buf.st_mode)) {
283 strcat( tmp, dir->d_name );
286 pack_file( filespec, dir->d_name, buf.st_size, buf.st_mtime );
291 printf(
"Error: Source directory does not exist!\n");
304 ts = filespec+(strlen(filespec)-1);
309 dd = filespec + (strlen(filespec) - 4);
318 printf(
"Creates a vp archive out of a FreeSpace data tree.\n\n" );
319 printf(
"Usage: cfilearchiver archive_name src_dir\n");
320 printf(
"Example: cfilearchiver freespace /tmp/freespace/data\n\n");
321 printf(
"Directory structure options:\n" );
322 printf(
" Effects (.ani .pcx .neb .tga)\n" );
323 printf(
" Fonts (.vf)\n" );
324 printf(
" Hud (.ani .pcx .tga\n" );
325 printf(
" Interface (.pcx .ani .tga)\n" );
326 printf(
" Maps (.pcx .ani .tga)\n" );
327 printf(
" Missions (.ntl .ssv), FS1(.fsm .fsc), FS2(.fs2 .fc2)\n" );
328 printf(
" Models (.pof)\n" );
329 printf(
" Music (.wav)\n" );
330 printf(
" Sounds/8b22k (.wav)\n" );
331 printf(
" Sounds/16b11k (.wav)\n" );
332 printf(
" Tables (.tbl)\n" );
333 printf(
" Voice/Briefing (.wav)\n" );
334 printf(
" Voice/Command briefings (.wav)\n" );
335 printf(
" Voice/Debriefing (.wav)\n" );
336 printf(
" Voice/Personas (.wav)\n" );
337 printf(
" Voice/Special (.wav)\n" );
338 printf(
" Voice/Training (.wav)\n" );
349 int main(
int argc,
char *argv[] )
356 printf(
"Usage: %s archive_name src_dir\n", argv[0] );
357 printf(
"Example: %s freespace c:\\freespace\\data\n", argv[0] );
358 printf(
"Creates an archive named freespace out of the\nfreespace data tree\n" );
359 printf(
"Press any key to exit...\n" );
368 p = strchr( archive,
'.' );
381 printf(
"Press any key to exit...\n" );
393 printf(
"Press any key to exit...\n" );
402 printf(
"Warning! Last directory must be named \"data\" (not case sensitive)\n");
419 printf(
"Data files written, appending index...\n" );
422 printf(
"Error appending index!\n");
424 printf(
"Press any key to exit...\n");
GLfloat GLfloat GLfloat GLfloat h
size_t fswrite_int(int *wint, FILE *stream)
char tmp_data[BLOCK_SIZE]
#define DIR_SEPARATOR_CHAR
void print_instructions()
#define DIR_SEPARATOR_STR
sprintf(buf,"(%f,%f,%f)", v3->xyz.x, v3->xyz.y, v3->xyz.z)
void pack_file(char *filespec, char *filename, int filesize, _fs_time_t time_write)
int verify_directory(char *filespec)
void pack_directory(char *filespec)
int main(int argc, char *argv[])
struct vp_header vp_header
int write_index(char *hf, char *df)
void add_directory(char *dirname)
GLsizei const GLchar ** path