ReadBinFileToBuffer - cSeqFileHelper

Reads a binary file returning the binary data in a newly allocated memory buffer

Type: Function

Return Data Type: Pointer

Parameters: String sName Integer ByRef iSize

ParameterDescription
sNameThe fully qualified name of the file to read
iSize (ByRef)This will return, by reference, the size of the file


Return Value

A memory address of a newly created buffer than contains the binary file. It is the developer's responsibility to dispose of the memory when done using it.


Syntax
Function ReadBinFileToBuffer String sName Integer ByRef iSize Returns Pointer

Call: Get ReadBinFileToBuffer sName (&iSize) to PointerVariable


Description

ReadBinFileToBuffer reads a file as binary data from the passed filename. It creates a memory buffer, reads the data into that buffer, returning the buffer address along with its length.

Address aBuffer
String sAppSrc sName
Integer iBinSize

Get psAppSrcPath of (phoWorkspace(ghoApplication)) to sAppSrc
Move (sAppSrc +"\Test.exe") to sName
// read in a binary file to buffer of size iBinSize
Get ReadBinFileToBuffer of oFileHelper sName (&iBinSize) to aBuffer

// do whatever you want with the data    
Send ProcessTheFile aBuffer iBinSize

// free the data when you are done
Move (Free(aBuffer)) to iVoid


Use WriteBinFileFromBuffer to write a binary file.