BinaryIO Class Reference

provides methods for file i/o as needed by the rest of steghide

`#include <BinaryIO.h>`

## Public Types

enum | MODE { READ , WRITE }

## Public Member Functions

| BinaryIO (void)
| BinaryIO (const std::string &fn, MODE m)
| ~BinaryIO (void)
const std::string & | getName (void) const
bool | is_open (void) const
bool | is_std (void) const
unsigned long | getPos (void) const
bool | eof (void) const
void | open (const std::string &fn, MODE m)
void | close (void)
BYTE | read8 (void)
UWORD16 | read16_le (void)
UWORD16 | read16_be (void)
UWORD32 | read32_le (void)
UWORD32 | read32_be (void)
UWORD32 | read_le (unsigned short n)
std::string | readstring (unsigned int len)
void | write8 (BYTE val)
void | write16_le (UWORD16 val)
void | write16_be (UWORD16 val)
void | write32_le (UWORD32 val)
void | write32_be (UWORD32 val)
void | write_le (UWORD32 val, unsigned short n)
void | writestring (const std::string &s)
FILE * | getStream (void) const

## Protected Member Functions

void | setStream (FILE *s)
void | setName (const std::string &fn)
MODE | getMode (void) const
void | setMode (MODE m)

## Private Member Functions

void | init (void)
void | set_open (bool o)
void | checkForce (const std::string &fn) const
bool | Fileexists (const std::string &fn) const

## Private Attributes

std::string | Name
FILE * | Stream
bool | FileOpen
MODE | Mode

## Member Enumeration Documentation

## MODE

enum BinaryIO::MODE

Enumerator
READ |
WRITE |

## Constructor & Destructor Documentation

## BinaryIO() [1/2]

BinaryIO::BinaryIO | ( | void |  | ) |

## BinaryIO() [2/2]

BinaryIO::BinaryIO | ( | const std::string & | fn,
|  | MODE | m )

construct a BinaryIO object

Parameters

  fn | the filename ("" to indicate stdin/stdout)
  m | the mode (BinaryIO::READ or BinaryIO::WRITE)

The file described by fn is opened in the given mode.

## ~BinaryIO()

BinaryIO::~BinaryIO | ( | void |  | ) |

## Member Function Documentation

## checkForce()

void BinaryIO::checkForce | ( | const std::string & | fn | ) | const

private

when opening a file in write mode perform various checks depending on the value of the force argument

## close()

void BinaryIO::close | ( | void |  | ) |

close the currently open file - it is save to call close() even if is_std() is true

## eof()

bool BinaryIO::eof | ( | void |  | ) | const

is the current state of this file at the end of the file

## Fileexists()

bool BinaryIO::Fileexists | ( | const std::string & | fn | ) | const

private

check if the file described by fn exists

Returns
  true iff a fopen call with fn as file name succeeded

## getMode()

MODE BinaryIO::getMode | ( | void |  | ) | const

inline protected

## getName()

const std::string & BinaryIO::getName | ( | void |  | ) | const

inline

get the name (with path) of this file

## getPos()

unsigned long BinaryIO::getPos | ( | void |  | ) | const

inline

get the current position in the current file

## getStream()

FILE * BinaryIO::getStream | ( | void |  | ) | const

inline

get the underlying cstdio FILE* pointer

## init()

void BinaryIO::init | ( | void |  | ) |

private

## is_open()

bool BinaryIO::is_open | ( | void |  | ) | const

inline

is this file currently opened ?

## is_std()

bool BinaryIO::is_std | ( | void |  | ) | const

inline

is this file a standard stream (stdin or stdout) ?

## open()

void BinaryIO::open | ( | const std::string & | fn,
|  | MODE | m )

open the file given by fn in the mode m

Parameters

  fn | a filename ("" to indicate stdin/stdout)
  m | the mode (BinaryIO::READ or BinaryIO::WRITE)

## read16_be()

UWORD16 BinaryIO::read16_be | ( | void |  | ) |

read two bytes from the file using big-endian byte ordering

## read16_le()

UWORD16 BinaryIO::read16_le | ( | void |  | ) |

read two bytes from the file using little-endian byte ordering

## read32_be()

UWORD32 BinaryIO::read32_be | ( | void |  | ) |

read four bytes from the file using big-endian byte ordering

## read32_le()

UWORD32 BinaryIO::read32_le | ( | void |  | ) |

read four bytes from the file using little-endian byte ordering

## read8()

BYTE BinaryIO::read8 | ( | void |  | ) |

read one byte from the file

## read_le()

UWORD32 BinaryIO::read_le | ( | unsigned short | n | ) |

read n bytes (little endian byte ordering)

Parameters

  n | the number of bytes to read (must be <= 4)

## readstring()

std::string BinaryIO::readstring | ( | unsigned int | len | ) |

read a string with length len from the file

## set_open()

void BinaryIO::set_open | ( | bool | o | ) |

inline private

## setMode()

void BinaryIO::setMode | ( | MODE | m | ) |

inline protected

## setName()

void BinaryIO::setName | ( | const std::string & | fn | ) |

inline protected

## setStream()

void BinaryIO::setStream | ( | FILE * | s | ) |

inline protected

## write16_be()

void BinaryIO::write16_be | ( | UWORD16 | val | ) |

write two bytes to the file using big-endian byte ordering

## write16_le()

void BinaryIO::write16_le | ( | UWORD16 | val | ) |

write two bytes to the file using little-endian byte ordering

## write32_be()

void BinaryIO::write32_be | ( | UWORD32 | val | ) |

write four bytes to the file using big-endian byte ordering

## write32_le()

void BinaryIO::write32_le | ( | UWORD32 | val | ) |

write four bytes to the file using little-endian byte ordering

## write8()

void BinaryIO::write8 | ( | BYTE | val | ) |

write one byte to the file

## write_le()

void BinaryIO::write_le | ( | UWORD32 | val,
|  | unsigned short | n )

write n bytes of val (little endian byte ordering)

Parameters

  n | the number of bytes to write (must be <= 4)
  val | the value

## writestring()

void BinaryIO::writestring | ( | const std::string & | s | ) |

## Member Data Documentation

## FileOpen

bool BinaryIO::FileOpen

private

## Mode

MODE BinaryIO::Mode

private

## Name

std::string BinaryIO::Name

private

## Stream

FILE* BinaryIO::Stream

private

The documentation for this class was generated from the following files:

- BinaryIO.h
- BinaryIO.cc