FileIO API

This chapter describes API used to develop a FileIO module by using ProFrame.

1. API List

2. General API

pfmFileIOOpen

Opens a file and gets its descriptor.

  • Prototype

    long pfmFileIOOpen( FILE **fd , char* path, char *fileName, char *mode )
  • Parameters

    Parameter Description

    fd

    File descriptor used to access the file.

    path

    Path to the file to open.

    fileName

    Name of the file to open.

    mode

    File permission modes.

    • FILE_READ: Read mode.

    • FILE_WRITE: Write mode.

    • FILE_READ_WRITE: Read/write mode.

    • FILE_WRITE_APPEND: Append mode.

    • FILE_READ_WRITE_APPEND: Read/append mode.

  • Return values

    Return Value Description

    RC_NRM

    Success

  • Example

    FILE *fd;
    PfmFileIOStruct pfmFileIOStruct = {"fioTEST01Data", 1, "F", 0, NULL, 0, NULL };
    …
    pfmFileIORead(&fd, &fmwFileIOStruct);
  • Related functions

    pfmFileIOClose

pfmFileIOClose

Closes a file.

  • Prototype

    long pfmFileIOClose( FILE **fd )
  • Parameters

    Parameter Description

    fd

    File descriptor of the file to close.

  • Return values

    Return Value Description

    RC_NRM

    Success

  • Example

    FILE *fd;
    ..
    pfmFileIOClose( &fd );
  • Related functions

    pfmFileIOOpen

pfmFileIORead

Reads a file and writes the data to a specified structure.

  • Prototype

    long pfmFileIORead( FILE **fd, PfmFileIOStruct *pfmFileIOStruct )
  • Parameters

    Parameter Description

    fd

    File descriptor returned by pfmFileOpen.

    pfmFileIOStruct

    Structure read from the file and relevant information.

    The following describes the pfmFileIOStruct structure.

    pfmFileIOStruct Description

    PfmFileIOStruct→structName

    Structure name.

    PfmFileIOStruct→arrayCount

    Iteration count of the structure.

    PfmFileIOStruct→convertType

    Type used when converting file contents to structures.

    • "F": Fixed Length

    • "D": Delimiter

    • "S": Convert SKIP, Buffer

    PfmFileIOStruct→resultCount

    Number of rows fetched from the file.

    PfmFileIOStruct→structData

    Structure buffer pointer.

    PfmFileIOStruct→structSize

    Structure size.

    PfmFileIOStruct→buf

    Buffer for each row of the file.

  • Return values

    Return Value Description

    RC_NRM

    Success

  • Example

    FILE *fd6;
    PfmFileIOStruct pfmFileIOStruct6;
    ...
    pfmFileIORead(&fd6, &fmwFileIOStruct6);
pfmFileIOWrite

Writes a file and releases the memory of messages created through a process such as marshal. Can be used for all message types because it includes separate functions for each message type.

  • Prototype

    long pfmFileIOWrite( FILE **fd , PfmFileIOStruct *pfmFileIOStruct )
  • Parameters

    Parameter Description

    fd

    File descriptor of the file to write to.

    pfmFileIOStruct

    Structure to write to the file and relevant information.

    The following describes the pfmFileIOStruct structure.

    pfmFileIOStruct Description

    PfmFileIOStruct→structName

    Structure name.

    PfmFileIOStruct→arrayCount

    Iteration count of the structure.

    PfmFileIOStruct→convertType

    Type used when converting structure data to a row.

    • "F": Fixed Length

    • "D": Delimiter

    • "S": Convert SKIP, Buffer

    PfmFileIOStruct→resultCount

    Number of rows written to the file.

    PfmFileIOStruct→structData

    Structure data to write to the file.

    PfmFileIOStruct→structSize

    Structure size.

    PfmFileIOStruct→buf

    Buffer used to write when convertType is "S".

  • Return values

    Return Value Description

    RC_NRM

    Success

  • Example

    FILE *fd;
    PfmFileIOStruct pfmFileIOStruct;
    ....
    pfmFileIOWrite(&fd, &pfmFileIOStruct);