[ Home ]

file.c File Reference

File I/O layer. More...

#include <stdio.h>
#include "file.h"
#include "../memory/memory.h"

Include dependency graph for file.c:


Functions

PUBLIC SW32 FS_FileLength (FILE *stream)
 Calculate file length.
PUBLIC SW32 FS_FileRead (void *ptr, size_t size, size_t nmemb, FILE *stream)
 Reads data from binary file stream.
PUBLIC SW32 FS_FileOpen (const char *filename, FILE **file)
 Open a file stream.
PUBLIC SW32 FS_FileLoad (const char *path, void **buffer)
 Load a file into memory.

Detailed Description

File I/O layer.

Author:
Michael Liebscher
Date:
2005

Function Documentation

PUBLIC SW32 FS_FileLength ( FILE *  stream  ) 

Calculate file length.

Parameters:
[in] filestream Pointer to valid FILE structure.
Returns:
Length of the file in bytes on success, otherwise -1.

Here is the caller graph for this function:

PUBLIC SW32 FS_FileLoad ( const char *  path,
void **  buffer 
)

Load a file into memory.

Parameters:
[in] path File name to load.
[in,out] buffer Buffer to hold data
Returns:
On success file length in bytes, otherwise -1. Returned data is NUL-terminated.
Note:
Caller is responsible for freeing buffered data. Data is also NUL-terminated.

Here is the call graph for this function:

Here is the caller graph for this function:

PUBLIC SW32 FS_FileOpen ( const char *  filename,
FILE **  file 
)

Open a file stream.

Parameters:
[in] filename Name of file to open.
[out] file FILE pointer.
Returns:
On success length of the file in bytes, otherwise -1.

Here is the call graph for this function:

Here is the caller graph for this function:

PUBLIC SW32 FS_FileRead ( void *  ptr,
size_t  size,
size_t  nmemb,
FILE *  stream 
)

Reads data from binary file stream.

Parameters:
[in,out] ptr Storage location.
[in] size Size of object in bytes.
[in] nmemb Number of objects to read.
[in] stream Stream to read from.
Returns:
Length of the file in bytes on success, otherwise -1.

Here is the caller graph for this function: