Advanced Strategic Command
Classes | Macros | Functions | Variables
basestrm.cpp File Reference

The various streams that ASC offers, like file and memory streams. More...

#include <stdio.h>
#include <ctype.h>
#include <cstdlib>
#include <stdlib.h>
#include <string>
#include <list>
#include "global.h"
#include <sys/stat.h>
#include <bzlib.h>
#include "basestrm.h"
#include <SDL_endian.h>
#include "util/messaginghub.h"
#include "oldlzw.cpp"
Include dependency graph for basestrm.cpp:

Go to the source code of this file.

Classes

struct  trleheader
 
class  ContainerCollector
 
struct  ContainerCollector::FileIndex
 
struct  FileLocation
 
class  PrivateCompressionData
 
class  PrivateDecompressionData
 

Macros

#define bzip_xor_byte   'M'
 

Functions

float SwapFloat (float f)
 
static int stream_seek (struct SDL_RWops *context, int offset, int whence)
 
static int stream_read (SDL_RWops *context, void *ptr, int size, int maxnum)
 
static int stream_close (SDL_RWops *context)
 
SDL_RWops * SDL_RWFromStream (tnstream *stream)
 
char * constructFileName (char *buf, int directoryLevel, const char *path, const char *filename)
 
bool isPathRelative (const ASCString &path)
 
ASCString constructFileName (int directoryLevel, const ASCString &path, ASCString filename)
 
void locateFile (const ASCString &filename, FileLocation *loc)
 
ASCString listContainer ()
 
int compressrle (const void *p, void *q)
 
bool patimat (const char *pat, const char *str, bool forceCaseInsensitivity)
 
bool patimat (const ASCString &pat, const ASCString &str, bool forceCaseInsensitivity)
 checks whether the regular expression pat matches the string str . More...
 
int checkforvaliddirectory (char *dir)
 
ASCString getnextfilenumname (const ASCString &first, const ASCString &suffix, int num)
 
bool exist (const ASCString &s)
 does a file s exist (wildcards allowed) More...
 
void opencontainer (const char *wildcard)
 
time_t get_filetime (const char *fileName)
 
int filesize (const char *name)
 
bool directoryExist (const ASCString &path)
 
void addSearchPath (const ASCString &path)
 
int getSearchPathNum ()
 
ASCString getSearchPath (int i)
 
char * extractPath (char *buf, const char *filename)
 
char * extractFileName (char *buf, const char *filename)
 
ASCString extractFileName (const ASCString &filename)
 
ASCString extractFileName_withoutSuffix (const ASCString &filename)
 
void appendbackslash (char *string)
 
void appendbackslash (ASCString &string)
 
int createDirectory (const char *name)
 
void convertPathDelimitters (ASCString &path)
 converts path delimitters from foreign operating systems to the ones used by the current operating system. On Linux, this function converts backslashes to slashes, on Windows vice versa More...
 

Variables

const int maxSearchDirNum = 30
 
int searchDirNum = 0
 
char * ascDirectory [maxSearchDirNum]
 
const char * containermagic = "NCBM"
 
const char * LZ_SIGNATURE = "MBLZW16"
 
const char * RLE_SIGNATURE = "MBRLE1"
 
const char * BZIP_SIGNATURE = "MBZLB2X!"
 
ContainerCollector containercollector
 
static const char asciiCodingTable [64]
 

Detailed Description

The various streams that ASC offers, like file and memory streams.

Definition in file basestrm.cpp.

Macro Definition Documentation

#define bzip_xor_byte   'M'

Function Documentation

void addSearchPath ( const ASCString path)

Definition at line 2517 of file basestrm.cpp.

References ascDirectory, constructFileName(), directoryExist(), and searchDirNum.

Referenced by initFileIO(), main(), and opencontainer().

void appendbackslash ( char *  string)
void appendbackslash ( ASCString string)

Definition at line 2602 of file basestrm.cpp.

References pathdelimitter, and pathdelimitterstring.

int checkforvaliddirectory ( char *  dir)

Definition at line 2255 of file basestrm.cpp.

References ASC_direct, closedir(), opendir(), and readdir().

int compressrle ( const void *  p,
void *  q 
)
char* constructFileName ( char *  buf,
int  directoryLevel,
const char *  path,
const char *  filename 
)
ASCString constructFileName ( int  directoryLevel,
const ASCString path,
ASCString  filename 
)

Definition at line 954 of file basestrm.cpp.

References appendbackslash(), ascDirectory, isPathRelative(), and pathdelimitter.

void convertPathDelimitters ( ASCString path)

converts path delimitters from foreign operating systems to the ones used by the current operating system. On Linux, this function converts backslashes to slashes, on Windows vice versa

Definition at line 2646 of file basestrm.cpp.

References foreignPathDelimitterString, and pathdelimitterstring.

Referenced by tfindfile::tfindfile().

int createDirectory ( const char *  name)

Definition at line 2609 of file basestrm.cpp.

Referenced by makeDirectory().

bool directoryExist ( const ASCString path)

Definition at line 2500 of file basestrm.cpp.

References closedir(), opendir(), and readdir().

Referenced by addSearchPath(), getDirectory(), and makeDirectory().

bool exist ( const ASCString s)
char* extractFileName ( char *  buf,
const char *  filename 
)
ASCString extractFileName ( const ASCString filename)

Definition at line 2579 of file basestrm.cpp.

References extractFileName().

ASCString extractFileName_withoutSuffix ( const ASCString filename)
char* extractPath ( char *  buf,
const char *  filename 
)

Definition at line 2548 of file basestrm.cpp.

References pathdelimitter.

Referenced by ContainerCollector::init(), and writegameoptions().

int filesize ( const char *  name)

Definition at line 2489 of file basestrm.cpp.

time_t get_filetime ( const char *  fileName)
ASCString getnextfilenumname ( const ASCString first,
const ASCString suffix,
int  num 
)

Definition at line 2418 of file basestrm.cpp.

References tfindfile::getnextname(), and ASCString::toString().

Referenced by executeUserAction().

ASCString getSearchPath ( int  i)
int getSearchPathNum ( )

Definition at line 2534 of file basestrm.cpp.

References searchDirNum.

Referenced by checkFileLoadability(), and showSearchPath().

bool isPathRelative ( const ASCString path)
ASCString listContainer ( )

Definition at line 1052 of file basestrm.cpp.

References ContainerCollector::listContainer().

Referenced by loadAllData(), and showSearchPath().

void locateFile ( const ASCString filename,
FileLocation loc 
)
void opencontainer ( const char *  wildcard)

Definition at line 2457 of file basestrm.cpp.

References addSearchPath(), ContainerCollector::init(), and searchDirNum.

Referenced by initFileIO().

bool patimat ( const char *  pat,
const char *  str,
bool  forceCaseInsensitivity 
)
bool patimat ( const ASCString pat,
const ASCString str,
bool  forceCaseInsensitivity = false 
)

checks whether the regular expression pat matches the string str .

This functions only understands dos/windows style wildcards: * and ?

Definition at line 2024 of file basestrm.cpp.

References patimat().

SDL_RWops* SDL_RWFromStream ( tnstream stream)
static int stream_close ( SDL_RWops *  context)
static

Definition at line 680 of file basestrm.cpp.

Referenced by SDL_RWFromStream().

static int stream_read ( SDL_RWops *  context,
void *  ptr,
int  size,
int  maxnum 
)
static

Definition at line 671 of file basestrm.cpp.

References MemoryStreamCopy::readdata().

Referenced by SDL_RWFromStream().

static int stream_seek ( struct SDL_RWops *  context,
int  offset,
int  whence 
)
static
float SwapFloat ( float  f)

Definition at line 312 of file basestrm.cpp.

Referenced by tnstream::readFloat().

Variable Documentation

char* ascDirectory[maxSearchDirNum]
Initial value:
= { NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL }

Definition at line 67 of file basestrm.cpp.

Referenced by addSearchPath(), constructFileName(), getSearchPath(), and tfindfile::tfindfile().

const char asciiCodingTable[64]
static
Initial value:
= { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '+', '/' }

Definition at line 1741 of file basestrm.cpp.

const char* BZIP_SIGNATURE = "MBZLB2X!"

Definition at line 90 of file basestrm.cpp.

Referenced by tanycompression::init().

ContainerCollector containercollector

Definition at line 871 of file basestrm.cpp.

const char* containermagic = "NCBM"

Definition at line 86 of file basestrm.cpp.

Referenced by tncontainerstream::tncontainerstream().

const char* LZ_SIGNATURE = "MBLZW16"

Definition at line 88 of file basestrm.cpp.

Referenced by tanycompression::init().

const int maxSearchDirNum = 30

Definition at line 65 of file basestrm.cpp.

Referenced by tfindfile::tfindfile().

const char* RLE_SIGNATURE = "MBRLE1"

Definition at line 89 of file basestrm.cpp.

Referenced by tanycompression::init().

int searchDirNum = 0