Atrinik Client  4.0
wrapper.c File Reference
#include <global.h>
#include <toolkit/string.h>
#include <toolkit/path.h>
#include <resources.h>

Go to the source code of this file.


void system_start (void)
void system_end (void)
static int mkdir_recurse (const char *path)
void mkdir_ensure (const char *path)
void copy_file (const char *filename, const char *filename_out)
void copy_if_exists (const char *from, const char *to, const char *src, const char *dst)
static void _rmrf (DIR *dir, const char *path)
void rmrf (const char *path)
void copy_rec (const char *src, const char *dst)
const char * get_config_dir (void)
void get_data_dir_file (char *buf, size_t len, const char *fname)
char * file_path (const char *path, const char *mode)
static StringBuffer * file_path_server_internal (void)
char * file_path_player (const char *path)
char * file_path_server (const char *path)
FILE * client_fopen_wrapper (const char *fname, const char *mode)
SDL_Surface * IMG_Load_wrapper (const char *file)
TTF_Font * TTF_OpenFont_wrapper (const char *file, int ptsize)

Detailed Description

General convenience functions for the client.

Definition in file wrapper.c.

Function Documentation

static void _rmrf ( DIR *  dir,
const char *  path 

Removes all the files in the specified directory.

dirThe directory.
pathPath to the directory.

Definition at line 215 of file wrapper.c.

void copy_file ( const char *  filename,
const char *  filename_out 

Copy a file.

filenameSource file.
filename_outDestination file.

Definition at line 153 of file wrapper.c.

void copy_if_exists ( const char *  from,
const char *  to,
const char *  src,
const char *  dst 

Copy a file/directory if it exists.

fromDirectory where to copy from.
toDirectort to copy to.
srcFile/directory to copy.
dstWhere to copy the file/directory to.

Definition at line 194 of file wrapper.c.

void copy_rec ( const char *  src,
const char *  dst 

Recursively copy a file or directory.

srcSource file/directory to copy.
dstWhere to copy to.

Definition at line 269 of file wrapper.c.

char* file_path ( const char *  path,
const char *  mode 

Get absolute path to the specified relative path. This path will typically point to the to client data directory (which is usually located in the user's home/appdata directory), but depending on the specified mode, extra actions may be performed. These ensure that if you're trying to access a file that does not yet exist in the client data directory, it will be read from the client installation directory instead (unless it's being appended to, in which case it will be copied to the client data directory first).

Generally, you should almost always use this when you need to construct a path, or use one of the many File wrapper functions.

fnameThe file path.
modeFile mode.
The absolute path. Must be freed.

Definition at line 369 of file wrapper.c.

char* file_path_player ( const char *  path)

Create a path to the per-player settings directory.

pathPath inside the per-player settings directory.
New path. Must be freed.

Definition at line 452 of file wrapper.c.

char* file_path_server ( const char *  path)

Create a path to the per-server settings directory.

pathPath inside the per-server settings directory.
New path. Must be freed.

Definition at line 476 of file wrapper.c.

static StringBuffer* file_path_server_internal ( void  )

Constructs a path leading to the chosen server settings directory. Used internally by file_path_player() and file_path_server().


Definition at line 428 of file wrapper.c.

const char* get_config_dir ( void  )

Get configuration directory.

The configuration directory.

Definition at line 303 of file wrapper.c.

void get_data_dir_file ( char *  buf,
size_t  len,
const char *  fname 

Get path to a file in the data directory.

bufBuffer where to store the path.
lenSize of buf.

Definition at line 331 of file wrapper.c.

void mkdir_ensure ( const char *  path)

Use mkdir_recurse() to ensure that destination 'path' exists, creating sub-directories of the path, if they do not exist yet. If you're using this to ensure directory path exists, make sure to end the 'path' string with a forward slash, otherwise the function will assume that the path is a file path.

pathThe path to ensure.

Definition at line 130 of file wrapper.c.

static int mkdir_recurse ( const char *  path)

Recursively creates directories from path.

Used by file_path().

pathThe path
0 on success, -1 otherwise

Definition at line 93 of file wrapper.c.

void rmrf ( const char *  path)

Recursively remove a directory and its contents.

Effectively same as 'rf -rf path'.

pathWhat to remove.

Definition at line 248 of file wrapper.c.

void system_end ( void  )

End the system.

Definition at line 51 of file wrapper.c.

void system_start ( void  )

Start the base system, setting caption name and window icon.

Definition at line 38 of file wrapper.c.