Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals   Related Pages  

file_manager_c Class Reference

File Manager Class. More...

#include <file.h>


Public Methods

 file_manager_c ()
 C'tor.

 ~file_manager_c ()
 D'tor.

ulong load_pak (const char *filename)
 load a pak file

void unload_pak (ulong n)
 unload a pak

void close_paks ()
 unload all pak

file_tcreate ()
 create a new file

void resize (file_t *file, ulong newsize)
 change file size

file_tload (const char *filename, bool async)
 load a file

void save (file_t *file, const char *filename)
 save a file

file_tload_from_disk (const char *filename, bool async)
 load a file from disk

file_tload_from_pak (const char *filename)
 load a file from a pak

void close (file_t *file)
 close a file

ulong seek (file_t *file, slong offset, ulong origin)
 Seek a file.

ulong tell (file_t *file)
 tell position

bool eof (file_t *file)
 end of file?

ulong read (void *out, ulong size, ulong n, file_t *file)
 read data from a file

ulong getch (file_t *file)
 read a character from a file

const char * gets (char *dst, ulong count, file_t *file)
 read a string from a file

void getpixel (file_t *file, char *r, char *g, char *b, char *a, char bpp)
 Read a pixel from a file.

ulong write (void *buf, ulong size, ulong n, file_t *file)
 write data to a file

slong putch (slong ch, file_t *file)
 write a character to a file

slong puts (const char *string, file_t *file)
 write a string to a file

void putpixel (file_t *file, char r, char g, char b, char a, char bpp)
 Write a pixel to a file.


Protected Attributes

list_c< file_t > * async_files
 A list of all asynchronous files.

char datadir [128]
 The data directory.


Detailed Description

The file manager class is responsible for all file access stuff. Loading, saving, reading and writing.

Definition at line 101 of file file.h.


Member Function Documentation

void close file_t   file
 

Closes a file by freeing it's buffer and the file_t pointer.

Parameters:
file  file to close

Definition at line 531 of file f_main.cpp.

References SafeArrayDelete, and SafeDelete.

Referenced by ~file_manager_c().

void close_paks  
 

Removes all paks from list of paks.

Definition at line 557 of file f_main.cpp.

References _log_printf(), and SafeArrayDelete.

Referenced by ~file_manager_c().

file_t * create  
 

Creates a new file in memory. The file will not be written to the file system before you call save() for it.

Definition at line 510 of file f_main.cpp.

References file_s::asyncloading, file_s::buf, file_s::pos, and file_s::size.

bool eof file_t   file
 

Returns the End Of File status. This is the is equivalent to "feof".

Parameters:
file  file to check

Definition at line 617 of file f_main.cpp.

ulong getch file_t   file
 

Returns the read char. This is the equivalent to "fgetc".

Parameters:
file  the file descriptor

Definition at line 57 of file f_in.cpp.

void getpixel file_t   file,
char *    r,
char *    g,
char *    b,
char *    a,
char    bpp
 

16 Bit Pixels are interpreted as they are in targa files (1/5/5/5):

Byte 1 Byte 2 where A is alpha and R, G and B are ARRRRRGG GGGBBBBB red green and blue values respectively

Parameters:
file  the file descriptor
r  pointer to where to store red
g  pointer to where to store green
b  pointer to where to store blue
a  pointer to where to store alpha
bpp  bits per pixel

Definition at line 95 of file f_in.cpp.

const char * gets char *    dst,
ulong    count,
file_t   file
 

Returns a pointer to the read string. This is the equivalent to "fgets".

Parameters:
dst  destination buffer
count  maximal count of chars
file  the file descriptor

Definition at line 71 of file f_in.cpp.

file_t * load const char *    filename,
bool    async
 

Tries to load the file from disk. If that fails, it will be loaded from the loaded paks. If that also fails NULL is returned, a pointer that can be used to refer to the file otherwise. The file is loaded completely into memory. If async is true, the file will be loaded in small pieces each frame.

Parameters:
filename  name of the file to load
async  asynchronously?

Definition at line 397 of file f_main.cpp.

References _log_printf().

file_t * load_from_disk const char *    filename,
bool    async
 

Tries to load the file from disk. If that fails, NULL is returned, a pointer that can be used to refer to the file otherwise.

Parameters:
filename  name of the file to load
async  load asynchronously?

Definition at line 160 of file f_main.cpp.

References _log_printf(), file_s::asyncloading, file_s::buf, file_s::f, file_s::pos, SafeDelete, and file_s::size.

file_t * load_from_pak const char *    filename
 

Tries to load the file from a pak. If that fails, NULL is returned, a pointer that can be used to refer to the file otherwise.

Parameters:
filename  name of the file to load

Definition at line 237 of file f_main.cpp.

References _log_printf(), file_s::buf, pak_header_s::entrycount, fileentry_s::filename, fileentry_s::offset, fileentry_s::realsize, SafeArrayDelete, SafeDelete, fileentry_s::size, and file_s::size.

ulong load_pak const char *    filename
 

Actually stores the name of a pak file for later loading when needed.

Parameters:
filename  the filename of the pak

Definition at line 422 of file f_main.cpp.

References _convert_file_path(), _log_printf(), and SafeArrayDelete.

slong putch slong    ch,
file_t   file
 

Returns character written. This is the is equivalent to "fputc".

Parameters:
c  character to put
file  file to use

Definition at line 54 of file f_out.cpp.

void putpixel file_t   file,
char    r,
char    g,
char    b,
char    a,
char    bpp
 

16 Bit Pixels are interpreted as they are in targa files (1/5/5/5):

Byte 1 Byte 2 where A is alpha and R, G and B are ARRRRRGG GGGBBBBB red green and blue values respectively

Parameters:
file  the file descriptor
r  red
g  green
b  blue
a  alpha
bpp  bits per pixel

Definition at line 92 of file f_out.cpp.

slong puts const char *    string,
file_t   file
 

Returns the number of bytes written. This is the is equivalent to "fputs".

Parameters:
string  string to write
file  the file descriptor

Definition at line 70 of file f_out.cpp.

ulong read void *    out,
ulong    size,
ulong    n,
file_t   file
 

Returns number of elements read. This is the is equivalent to "fread".

Parameters:
out  buffer to write to
size  size of items to read
n  number of items to read
file  file descriptor

Definition at line 141 of file f_in.cpp.

void resize file_t   file,
ulong    newsize
 

Changes file size to newsize. If newsize is larger than the current size of the file, the contents of the new bytes is undefined. If newsize is smaller, every data after newsize bytes will be lost. This function is usually only used by the write and put* functions.

Parameters:
file  file to resize
newsize  new size

Definition at line 482 of file f_main.cpp.

References SafeArrayDelete.

void save file_t   file,
const char *    filename
 

Writes the file to the file system.

Parameters:
file  the file to save
filename  the filename to save to

Definition at line 450 of file f_main.cpp.

ulong seek file_t   file,
slong    offset,
ulong    origin
 

Sets the position pointer to a given position. The syntax is equivalent to "fseek".

Parameters:
f  file to seek
offset  where to seek
origin  seek from where

Definition at line 590 of file f_main.cpp.

ulong tell file_t   file
 

Returns the position pointer. This is the is equivalent to "ftell"

Parameters:
f  file to check

Definition at line 546 of file f_main.cpp.

void unload_pak ulong    n
 

Removes pak n from list of paks.

Parameters:
n  number of pak to unload

Definition at line 574 of file f_main.cpp.

References _log_printf(), and SafeArrayDelete.

ulong write void *    buf,
ulong    size,
ulong    n,
file_t   file
 

Returns number of elements written. This is the is equivalent to "fwrite".

Parameters:
buf  buffer to write
size  size of items to write
n  number of items to write
file  file descriptor

Definition at line 136 of file f_out.cpp.


The documentation for this class was generated from the following files:
Generated on Wed Dec 18 15:48:49 2002 for omicron engine by doxygen1.2.18