Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vsnet_dloadmgr.cpp File Reference

Go to the source code of this file.

Classes

struct  stat
 

Namespaces

 VsnetDownload
 
 VsnetDownload::Client
 
 VsnetDownload::Server
 

Constant Groups

 VsnetDownload
 
 VsnetDownload::Client
 
 VsnetDownload::Server
 

Macros

#define R_OK   1
 
#define W_OK   2
 
#define CASE(a)
 

Functions

void getZoneInfoBuffer (unsigned short zoneid, NetBuffer &netbuf)
 
int vs_access (const char *name, int mode)
 
int lstat (const char *name, struct stat *buf)
 
 VsnetDownload::Server::LOCALCONST_DEF (Manager, int, _packetWorkahead, 5) Manager
 
const char * getState (State s)
 

Macro Definition Documentation

#define CASE (   a)
Value:
case a: \
return #a; break

Definition at line 832 of file vsnet_dloadmgr.cpp.

Referenced by getState().

#define R_OK   1

Definition at line 20 of file vsnet_dloadmgr.cpp.

Referenced by vs_access().

#define W_OK   2

Definition at line 25 of file vsnet_dloadmgr.cpp.

Referenced by vs_access().

Function Documentation

const char* getState ( State  s)

Definition at line 836 of file vsnet_dloadmgr.cpp.

References CASE, VsnetDownload::Client::Completed, VsnetDownload::Client::FragmentReceived, VsnetDownload::Client::Idle, VsnetDownload::Client::Queued, VsnetDownload::Client::Requested, VsnetDownload::Client::Resolved, and VsnetDownload::Client::Resolving.

837 {
838  switch (s)
839  {
840  CASE( Idle );
841  CASE( Queued );
842  CASE( Resolving );
843  CASE( Resolved );
844  CASE( Requested );
846  CASE( Completed );
847  default:
848  return "Unknown state";
849  }
850 }
void getZoneInfoBuffer ( unsigned short  zoneid,
NetBuffer netbuf 
)
int lstat ( const char *  name,
struct stat buf 
)

Definition at line 816 of file vsnet_dloadmgr.cpp.

References stat::st_size.

817 {
818  FILE *f = VSFileSystem::OpenFile( name, "rb" );
819  if (f == NULL) return -1;
820  int retval = -1;
821  if (VSFileSystem::Fseek( f, 0, SEEK_END ) == 0) {
822  buf->st_size = VSFileSystem::Ftell( f );
823  if (buf->st_size >= 0) retval = 0;
824  }
825  VSFileSystem::Close( f );
826  return retval;
827 }
int vs_access ( const char *  name,
int  mode 
)

Definition at line 793 of file vsnet_dloadmgr.cpp.

References fclose, fopen, R_OK, and W_OK.

794 {
795  FILE *fp;
796  if (mode&R_OK) {
797  fp = fopen( name, "rb" );
798  if (fp)
799  fclose( fp );
800  else
801  return -1;
802  }
803  if (mode&W_OK) {
804  fp = fopen( name, "r+b" ); //NOTE: any other mode may destroy existing data
805  if (fp)
806  fclose( fp );
807  else
808  return -1;
809  }
810  return 1;
811 }