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

Defines

#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 .
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)
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

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.


Define Documentation

#define bzip_xor_byte   'M'

Definition at line 84 of file basestrm.cpp.

Referenced by libbzip_compression::close_compression(), libbzip_decompression::readdata(), and libbzip_compression::writedata().


Function Documentation

void addSearchPath ( const ASCString path  ) 

Definition at line 2503 of file basestrm.cpp.

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

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

void appendbackslash ( ASCString string  ) 

Definition at line 2588 of file basestrm.cpp.

References pathdelimitter, and pathdelimitterstring.

void appendbackslash ( char *  string  ) 

Definition at line 2582 of file basestrm.cpp.

Referenced by checkbi3dir(), constructFileName(), getbipath(), ConfigurationFileLocatorCore::getDefaultDirectory(), ConfigurationFileLocatorCore::getSpecialPath(), and initFileIO().

int checkforvaliddirectory ( char *  dir  ) 

Definition at line 2241 of file basestrm.cpp.

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

int compressrle ( const void *  p,
void *  q 
)

Definition at line 1890 of file basestrm.cpp.

References trleheader::id, min(), trleheader::rle, trleheader::size, trleheader::x, and trleheader::y.

Referenced by tnstream::writeImage().

ASCString constructFileName ( int  directoryLevel,
const ASCString path,
ASCString  filename 
)

Definition at line 942 of file basestrm.cpp.

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

char* constructFileName ( char *  buf,
int  directoryLevel,
const char *  path,
const char *  filename 
)

Definition at line 861 of file basestrm.cpp.

Referenced by addSearchPath(), get_filetime(), ContainerCollector::init(), locateFile(), makeDirectory(), ReplayRecorder::start(), tfindfile::tfindfile(), tn_c_lzw_filestream::tn_c_lzw_filestream(), tn_file_buf_stream::tn_file_buf_stream(), ASCImageArrayProperty::toString(), ASCImageProperty::toString(), and WholeMapRenderer::writePNG().

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 2632 of file basestrm.cpp.

References foreignPathDelimitterString, and pathdelimitterstring.

Referenced by tfindfile::tfindfile().

int createDirectory ( const char *  name  ) 

Definition at line 2595 of file basestrm.cpp.

Referenced by makeDirectory().

bool directoryExist ( const ASCString path  ) 

Definition at line 2486 of file basestrm.cpp.

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

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

bool exist ( const ASCString s  ) 

does a file s exist (wildcards allowed)

Definition at line 2430 of file basestrm.cpp.

References tfindfile::getnextname().

Referenced by tdlgengine::addkey(), tdlgengine::addmarkedkey(), StartMultiplayerGame::Apply(), GameMap::beginTurn(), CargoDialog::CargoDialog(), checkbi3dir(), checkFileLoadability(), DiscoverResources::DiscoverResources(), GameMap::endRound(), FileCache::FileCache(), getbipath(), ConfigurationFileLocatorCore::getConfigFileName(), Locale::getLocalizedFile(), DiplomacyCommand::go(), loadLocalizedMessages(), loadWave(), MailOptionsDialog::MailOptionsDialog(), mapeditorMainThread(), readgameoptions(), and UnitInfoDialog::UnitInfoDialog().

ASCString extractFileName ( const ASCString filename  ) 

Definition at line 2565 of file basestrm.cpp.

References extractFileName().

char* extractFileName ( char *  buf,
const char *  filename 
)

Definition at line 2550 of file basestrm.cpp.

Referenced by extractFileName(), extractFileName_withoutSuffix(), and ContainerCollector::init().

ASCString extractFileName_withoutSuffix ( const ASCString filename  ) 

Definition at line 2571 of file basestrm.cpp.

References extractFileName().

Referenced by VehicleType::runTextIO(), TerrainType::Weather::runTextIO(), ObjectType::runTextIO(), BuildingType::runTextIO(), ASCImageArrayProperty::toString(), and ASCImageProperty::toString().

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

Definition at line 2534 of file basestrm.cpp.

References pathdelimitter.

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

int filesize ( const char *  name  ) 

Definition at line 2475 of file basestrm.cpp.

time_t get_filetime ( const char *  fileName  ) 

Definition at line 2454 of file basestrm.cpp.

References constructFileName(), FileLocation::container, FileLocation::directoryLevel, FileLocation::found, tn_file_buf_stream::get_time(), locateFile(), and maxFileStringSize.

Referenced by process_ASC_map(), and process_BI_map().

ASCString getnextfilenumname ( const ASCString first,
const ASCString suffix,
int  num 
)

Definition at line 2404 of file basestrm.cpp.

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

Referenced by executeUserAction().

ASCString getSearchPath ( int  i  ) 

Definition at line 2525 of file basestrm.cpp.

References ascDirectory, and searchDirNum.

Referenced by ASC_PG_App::ASC_PG_App(), checkFileLoadability(), initFileIO(), main(), readgameoptions(), and showSearchPath().

int getSearchPathNum (  ) 

Definition at line 2520 of file basestrm.cpp.

References searchDirNum.

Referenced by checkFileLoadability(), and showSearchPath().

bool isPathRelative ( const ASCString path  ) 

Definition at line 922 of file basestrm.cpp.

References pathdelimitter.

Referenced by constructFileName(), ConfigurationFileLocatorCore::getConfigFileName(), and initFileIO().

ASCString listContainer (  ) 

Definition at line 1040 of file basestrm.cpp.

References containercollector, and ContainerCollector::listContainer().

Referenced by showSearchPath().

void locateFile ( const ASCString filename,
FileLocation loc 
)

Definition at line 996 of file basestrm.cpp.

References constructFileName(), ContainerCollector::FileIndex::container, FileLocation::container, containercollector, FileLocation::directoryLevel, ContainerCollector::FileIndex::directoryLevel, FileLocation::found, ContainerCollector::getfile(), and searchDirNum.

Referenced by executeUserAction(), get_filetime(), and tn_c_lzw_filestream::tn_c_lzw_filestream().

void opencontainer ( const char *  wildcard  ) 

Definition at line 2443 of file basestrm.cpp.

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

Referenced by initFileIO().

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 2010 of file basestrm.cpp.

References patimat().

bool patimat ( const char *  pat,
const char *  str,
bool  forceCaseInsensitivity 
)

Definition at line 1983 of file basestrm.cpp.

References CASE_SENSITIVE_FILE_NAMES.

Referenced by SavegameSelectionWindow::fileNameEntered(), FileSelectionWindow::fileNameEntered(), ContainerCollector::init(), loadStartupMap(), mapeditorMainThread(), patimat(), readClipboard(), and tfindfile::tfindfile().

SDL_RWops* SDL_RWFromStream ( tnstream stream  ) 

Definition at line 681 of file basestrm.cpp.

References stream_close(), stream_read(), and stream_seek().

Referenced by getFieldMask(), IconRepository::getIcon(), loadASCFieldImage(), loadASCFieldImageArray(), loadWave(), Surface::readImageFile(), ASC_PG_App::setIcon(), and StartupScreen::StartupScreen().

static int stream_close ( SDL_RWops *  context  )  [static]

Definition at line 668 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 659 of file basestrm.cpp.

References MemoryStreamCopy::readdata().

Referenced by SDL_RWFromStream().

static int stream_seek ( struct SDL_RWops *  context,
int  offset,
int  whence 
) [static]

Definition at line 644 of file basestrm.cpp.

References MemoryStreamCopy::getPosition(), MemoryStreamCopy::getSize(), and MemoryStreamCopy::seek().

Referenced by SDL_RWFromStream().

float SwapFloat ( float  f  ) 

Definition at line 305 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 1727 of file basestrm.cpp.

Referenced by ASCIIEncodingStream::flush(), and ASCIIEncodingStream::put().

const char* BZIP_SIGNATURE = "MBZLB2X!"

Definition at line 90 of file basestrm.cpp.

Referenced by tanycompression::init().

ContainerCollector containercollector

Definition at line 859 of file basestrm.cpp.

Referenced by listContainer(), locateFile(), opencontainer(), and tfindfile::tfindfile().

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

Definition at line 66 of file basestrm.cpp.

Referenced by addSearchPath(), getSearchPath(), getSearchPathNum(), ContainerCollector::init(), locateFile(), opencontainer(), and tfindfile::tfindfile().


Generated on Mon May 21 01:30:36 2012 for Advanced Strategic Command by  doxygen 1.5.1