Version 6.3
Copyright © 2005 - 2012 Lowell D. Thomas
APG
  … ABNF Parser Generator
All Data Structures Files Functions Variables Typedefs Macros Pages
Functions
Files.c File Reference

A few commonly used functions for reading and writing files. More...

#include "ApgUtilities.h"

Go to the source code of this file.

Functions

apg_uint uiGetFileSize (const char *cpFileName)
 
apg_uint uiGetFile (const char *cpFileName, void *vpBuffer)
 
apg_uint uiWriteFile (const char *cpFileName, void *vpData, apg_uint uiDataLen)
 

Detailed Description

A few commonly used functions for reading and writing files.

Definition in file Files.c.

Function Documentation

◆ uiGetFile()

apg_uint uiGetFile ( const char *  cpFileName,
void *  vpBuffer 
)

Read an entire file into memory.

Parameters
cpFileNamethe name of the file to get
vpBufferpointer to the memory area to read the file into.
See also
uiGetFileSize()
Returns
the file size on success, 0 if the file does not exist

Definition at line 71 of file Files.c.

◆ uiGetFileSize()

apg_uint uiGetFileSize ( const char *  cpFileName)

Get the size of a file in bytes.

Useful when dynamically allocating a buffer for reading the entire file.

Parameters
cpFileNamethe name of the file whose size to get
See also
uiGetFile()
Returns
the file size on success, 0 if the file does not exist

Definition at line 40 of file Files.c.

◆ uiWriteFile()

apg_uint uiWriteFile ( const char *  cpFileName,
void *  vpData,
apg_uint  uiDataLen 
)

Write data into a file. If the file already exists its data is overwritten.

Parameters
cpFileNamethe name of the file to write
vpDatapointer to the memory area to write.
uiDataLenthe number of bytes of data to write
Returns
the number of bytes written. If not equal to uiDataLen an error occurred.

Definition at line 108 of file Files.c.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/licenses.html or write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.