12 #include "networking/const.h"
25 namespace VSFileSystem
95 extern vector< std::string >
curdir;
96 extern vector< std::string >
savedpwd;
123 extern vector< string >
Rootdir;
138 FILE *
vs_open(
const char *filename,
const char *mode );
139 size_t vs_read(
void *ptr,
size_t size,
size_t nmemb, FILE *fp );
140 size_t vs_write(
const void *ptr,
size_t size,
size_t nmemb, FILE *fp );
141 int vs_fseek( FILE *fp,
long offset,
int whence );
148 int vs_fprintf( FILE *fp,
const char *format, ... );
154 void vs_dprintf(
char level,
const char *format, ... );
156 int vs_fscanf( FILE *fp,
const char *format, ... );
161 return fscanf( fp, format, a );
163 template <
class A,
class B >
164 int vs_fscanf( FILE *fp,
const char *format, A *a, B *b )
166 return fscanf( fp, format, a, b );
168 template <
class A,
class B,
class C >
169 int vs_fscanf( FILE *fp,
const char *format, A *a, B *b, C *c )
171 return fscanf( fp, format, a, b, c );
173 template <
class A,
class B,
class C,
class D >
174 int vs_fscanf( FILE *fp,
const char *format, A *a, B *b, C *c, D *d )
176 return fscanf( fp, format, a, b, c, d );
178 template <
class A,
class B,
class C,
class D,
class E >
179 int vs_fscanf( FILE *fp,
const char *format, A *a, B *b, C *c, D *d, E *e )
181 return fscanf( fp, format, a, b, c, d, e );
183 template <
class A,
class B,
class C,
class D,
class E,
class F >
184 int vs_fscanf( FILE *fp,
const char *format, A *a, B *b, C *c, D *d, E *e, F *
f )
186 return fscanf( fp, format, a, b, c, d, e, f );
221 string GetHashName(
const std::string &name,
const class Vector &scale,
int faction );
253 void InitPaths(
string conf,
string subdir =
"" );
304 char *pk3_extracted_file;
308 void checkExtracted();
317 string subdirectoryname;
318 string directoryname;
327 return pk3_extracted_file;
341 return this->pk3_extracted_file;
367 size_t Read(
void *ptr,
size_t length );
370 size_t Write(
const void *ptr,
size_t length );
371 size_t Write(
const string &content );
376 int Fscanf(
const char *format, ... );
386 ret = fscanf( fp, format, a );
390 int ret = -1, readbytes = 0;
391 int length = strlen( format );
392 int newlength = length+3;
393 char *newformat =
new char[newlength];
394 memset( newformat, 0, newlength );
395 memcpy( newformat, format, length );
396 strcat( newformat,
"%n" );
397 ret = sscanf( this->pk3_extracted_file+offset, newformat, a, &readbytes );
399 std::cerr<<
"FSCANF : sscanf read "<<readbytes<<
" bytes - OFFSET="<<offset<<
" VALUES : a="<<(*a)<<std::endl;
400 this->offset += readbytes;
406 template <
class A,
class B >
407 int Fscanf(
const char *format, A *a, B *b )
411 ret = fscanf( fp, format, a, b );
415 int ret = -1, readbytes = 0;
416 int length = strlen( format );
417 int newlength = length+3;
418 char *newformat =
new char[newlength];
419 memset( newformat, 0, newlength );
420 memcpy( newformat, format, length );
421 strcat( newformat,
"%n" );
422 ret = sscanf( this->pk3_extracted_file+offset, newformat, a, b, &readbytes );
424 std::cerr<<
"FSCANF : sscanf read "<<readbytes<<
" bytes - OFFSET="<<offset<<
" VALUES : a="<<(*a)<<
", b="<<(*b)
426 this->offset += readbytes;
432 template <
class A,
class B,
class C >
433 int Fscanf(
const char *format, A *a, B *b, C *c )
437 ret = fscanf( fp, format, a, b, c );
441 int ret = -1, readbytes = 0;
442 int length = strlen( format );
443 int newlength = length+3;
444 char *newformat =
new char[newlength];
445 memset( newformat, 0, newlength );
446 memcpy( newformat, format, length );
447 strcat( newformat,
"%n" );
448 ret = sscanf( this->pk3_extracted_file+offset, newformat, a, b, c, &readbytes );
450 std::cerr<<
"FSCANF : sscanf read "<<readbytes<<
" bytes - OFFSET="<<offset<<
" VALUES : a="<<(*a)<<
", b="<<(*b)
451 <<
", c="<<(*c)<<std::endl;
452 this->offset += readbytes;
458 template <
class A,
class B,
class C,
class D >
459 int Fscanf(
const char *format, A *a, B *b, C *c, D *d )
463 ret = fscanf( fp, format, a, b, c, d );
467 int ret = -1, readbytes = 0;
468 int length = strlen( format );
469 int newlength = length+3;
470 char *newformat =
new char[newlength];
471 memset( newformat, 0, newlength );
472 memcpy( newformat, format, length );
473 strcat( newformat,
"%n" );
474 ret = sscanf( this->pk3_extracted_file+offset, newformat, a, b, c, d, &readbytes );
476 this->offset += readbytes;
482 template <
class A,
class B,
class C,
class D,
class E >
483 int Fscanf(
const char *format, A *a, B *b, C *c, D *d, E *e )
487 ret = fscanf( fp, format, a, b, c, d, e );
491 int ret = -1, readbytes = 0;
492 int length = strlen( format );
493 int newlength = length+3;
494 char *newformat =
new char[newlength];
495 memset( newformat, 0, newlength );
496 memcpy( newformat, format, length );
497 strcat( newformat,
"%n" );
498 ret = sscanf( this->pk3_extracted_file+offset, newformat, a, b, c, d, e, &readbytes );
500 this->offset += readbytes;
506 template <
class A,
class B,
class C,
class D,
class E,
class F >
507 int Fscanf(
const char *format, A *a, B *b, C *c, D *d, E *e, F *
f )
511 ret = fscanf( fp, format, a, b, c, d, e, f );
515 int ret = -1, readbytes = 0;
516 int length = strlen( format );
517 int newlength = length+3;
518 char *newformat =
new char[newlength];
519 memset( newformat, 0, newlength );
520 memcpy( newformat, format, length );
521 strcat( newformat,
"%n" );
522 ret = sscanf( this->pk3_extracted_file+offset, newformat, a, b, c, d, e, f, &readbytes );
524 this->offset += readbytes;
531 int Fprintf(
const char *format, ... );
538 void GoTo(
long offset );
546 return this->filename;
550 return this->directoryname;
554 return this->subdirectoryname;
558 return this->rootname;
563 this->filename = filename;
567 this->directoryname = directory;
571 this->subdirectoryname = subdirectory;
575 this->rootname = root;
607 #if defined (_WIN32) && !defined (__CYGWIN__)
609 int scandir(
const char *dirname,
struct dirent ***namelist,
610 int (*select)(
const struct dirent* ),
611 int (*compar)(
const struct dirent**,
const struct dirent** ) );