_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

Classes
iolib.cpp File Reference
#include "stratagus.h"
#include "iolib.h"
#include "game.h"
#include "iocompat.h"
#include "map.h"
#include "parameters.h"
#include "util.h"
#include "SDL.h"
#include <map>
#include <stdarg.h>
#include <stdio.h>
#include <zlib.h>
#include <bzlib.h>

Classes

class  CFile::PImpl
 
class  RawFileWriter
 
class  GzFileWriter
 

Functions

iolib.cpp - Compression-IO helper functions.
static Sint64 sdl_size (SDL_RWops *context)
 
static Sint64 sdl_seek (SDL_RWops *context, Sint64 offset, int whence)
 
static size_t sdl_read (SDL_RWops *context, void *ptr, size_t size, size_t maxnum)
 
static size_t sdl_write (SDL_RWops *context, const void *ptr, size_t size, size_t num)
 
static int sdl_close (SDL_RWops *context)
 
static int gzseek (CFile *file, unsigned offset, int whence)
 
static void bzseek (BZFILE *file, unsigned offset, int)
 
static bool FindFileWithExtension (char(&file)[PATH_MAX])
 
static void LibraryFileName (const char *file, char(&buffer)[PATH_MAX])
 
std::string LibraryFileName (const char *file)
 Build library path name. More...
 
bool CanAccessFile (const char *filename)
 
int ReadDataDirectory (const char *dirname, std::vector< FileList > &fl)
 Read the contents of a directory. More...
 
FileWriterCreateFileWriter (const std::string &filename)
 
std::vector< std::string > QuoteArguments (std::vector< std::string > args)
 

Function Documentation

◆ bzseek()

static void bzseek ( BZFILE *  file,
unsigned  offset,
int   
)
static

Seek on compressed input. (I hope newer libs support it directly)

Parameters
fileFile handle
offsetSeek position
whenceHow to seek

◆ CanAccessFile()

bool CanAccessFile ( const char *  filename)

◆ CreateFileWriter()

FileWriter* CreateFileWriter ( const std::string &  filename)

Create FileWriter

◆ FindFileWithExtension()

static bool FindFileWithExtension ( char(&)  file[PATH_MAX])
static

Find a file with its correct extension ("", ".gz" or ".bz2")

Parameters
fileThe string with the file path. Upon success, the string is replaced by the full filename with the correct extension.
filesizeSize of the file buffer
Returns
true if the file has been found.

◆ gzseek()

static int gzseek ( CFile file,
unsigned  offset,
int  whence 
)
static

Seek on compressed input. (Newer libs support it directly)

Parameters
fileFile
offsetSeek position
whenceHow to seek

◆ LibraryFileName() [1/2]

std::string LibraryFileName ( const char *  file)

Build library path name.

◆ LibraryFileName() [2/2]

static void LibraryFileName ( const char *  file,
char(&)  buffer[PATH_MAX] 
)
static

Generate a filename into library.

Try current directory, user home directory, global directory. This supports .gz, .bz2 and .zip.

Parameters
fileFilename to open.
bufferAllocated buffer for generated filename.

◆ QuoteArguments()

std::vector<std::string> QuoteArguments ( std::vector< std::string >  args)

Quote arguments for usage in calls to system(), popen() and similar. Really only needed on Windows, where all these calls just concatenate all arguments with a space and pass the full string to the next process.

◆ ReadDataDirectory()

int ReadDataDirectory ( const char *  dirname,
std::vector< FileList > &  fl 
)

Read the contents of a directory.

Generate a list of files within a specified directory

Parameters
dirnameDirectory to read.
flFilelist pointer.
Returns
the number of entries added to FileList.

◆ sdl_close()

static int sdl_close ( SDL_RWops *  context)
static

◆ sdl_read()

static size_t sdl_read ( SDL_RWops *  context,
void ptr,
size_t  size,
size_t  maxnum 
)
static

◆ sdl_seek()

static Sint64 sdl_seek ( SDL_RWops *  context,
Sint64  offset,
int  whence 
)
static

◆ sdl_size()

static Sint64 sdl_size ( SDL_RWops *  context)
static

◆ sdl_write()

static size_t sdl_write ( SDL_RWops *  context,
const void ptr,
size_t  size,
size_t  num 
)
static
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.