Home > Support > Documentation

rtxFile.h File Reference

Common runtime functions for reading from or writing to files. More...

#include "rtxsrc/rtxContext.h"

Go to the source code of this file.


Functions

int rtxFileReadBinary (OSCTXT *pctxt, const char *filePath, OSOCTET **ppMsgBuf, size_t *pLength)
 This function reads the entire contents of a binary file into memory.
int rtxFileReadText (OSCTXT *pctxt, const char *filePath, OSOCTET **ppMsgBuf, size_t *pLength)
 This function reads the entire contents of an ASCII text file into memory.

Detailed Description

Common runtime functions for reading from or writing to files.

Definition in file rtxFile.h.


Function Documentation

int rtxFileReadBinary ( OSCTXT pctxt,
const char *  filePath,
OSOCTET **  ppMsgBuf,
size_t *  pLength 
)

This function reads the entire contents of a binary file into memory.

A memory buffer is allocated for the file contents using the run-time memory management functions.

Parameters:
pctxt Pointer to context block structure.
filePath Complete file path name of file to read.
ppMsgBuf Pointer to message buffer to receive allocated memory pointer.
pLength Pointer to integer to receive length of data read.
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • RTERR_FILNOTFOU = file not found
  • RTERR_FILEREAD = file read error (see errno)

int rtxFileReadText ( OSCTXT pctxt,
const char *  filePath,
OSOCTET **  ppMsgBuf,
size_t *  pLength 
)

This function reads the entire contents of an ASCII text file into memory.

A memory buffer is allocated for the file contents using the run-time memory management functions. This function is identical to rtxReadFileBinary except that a) the file is opened in text mode, and b) and extra byte is allocated at the end for a null-terminator character.

Parameters:
pctxt Pointer to context block structure.
filePath Complete file path name of file to read.
ppMsgBuf Pointer to message buffer to receive allocated memory pointer.
pLength Pointer to integer to receive length of data read.
Returns:
Completion status of operation:
  • 0 (ASN_OK) = success,
  • RTERR_FILNOTFOU = file not found
  • RTERR_FILEREAD = file read error (see errno)