Skip to content

ReadBinFileToBuffer - cSeqFileHelper

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

Type: Function
Return Data Type: Pointer

Parameters

Parameter Type Description
sName String The fully qualified name of the file to read
ByRef iSize Integer This will return, by reference, the size of the file

Syntax

Function ReadBinFileToBuffer String sName ByRef Integer iSize Returns Pointer

Call Example

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.

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.