WXP C++ Library Version 6.74.9
Loading...
Searching...
No Matches
WXP::File Class Reference

This class accesses files. More...

#include "../include/File.h"

Inheritance diagram for WXP::File:
WXP::FileAttr

Public Types

enum  Type {
  REG , PIPE , STDIO , FIFO ,
  DEVICE , SOCKETC , SOCKETS , HTTP ,
  FTP
}
enum  Format {
  UNK , WXP , NETCDF , GRIB ,
  BUFR , UNISYS , NONE
}

Public Member Functions

int init ()
 File (const char *file, const char *raccess)
 File (String &file, const char *raccess)
 File (const char *file, int raccess)
 File ()
 ~File ()
int open (const char *file, const char *raccess)
int open (String &file, const char *raccess)
int open (const char *file, int raccess)
int getLine (char *string, int len)
int getLine (String &string)
int skipLine ()
bool isOpen ()
int rewind ()
int close ()
bool endFile ()
int scanf (const char *fmt,...)
int printf (const char *fmt,...)
int read (unsigned char *buf, int size, int num)
int read (unsigned char *buf, int size)
int read (Buffer &buf, int size)
int read (Buffer &buf)
int write (const unsigned char *buf, int size, int num)
int write (const unsigned char *buf, int size)
int tell ()
int seek (int byte, int where)
int seek (int byte)
int setShare (int mode)
FILE * getFP ()

Static Public Attributes

static const int FILE_LENGTH = 200
Static Public Attributes inherited from WXP::FileAttr
static const int READ = 0
static const int WRITE = 1
static const int APPEND = 2

Detailed Description

This class accesses files.

Author
Dan Vietor

Constructor & Destructor Documentation

◆ File() [1/4]

File::File ( const char * file,
const char * raccess )

Constructor. Opens file with access

Parameters
fileFilename to open
raccessFile access (r, w, a, r+, see fopen)

References open().

◆ File() [2/4]

File::File ( String & file,
const char * raccess )

Constructor. Opens file with access

Parameters
fileFilename to open
accessFile access (r, w, a, r+, see fopen)

References WXP::String::get(), and open().

◆ File() [3/4]

File::File ( const char * file,
int raccess )

Constructor. Opens file with access

Parameters
fileFilename to open
raccessFile access READ, WRITE, APPEND

References open().

◆ File() [4/4]

File::File ( )

Constructor. Initializes class data

References init().

◆ ~File()

File::~File ( )

Destructor. Closes file

References close().

Member Function Documentation

◆ close()

◆ endFile()

bool File::endFile ( )

Checks for end of file

Returns
True if end of file

Referenced by WXP::ModelSpec::set().

◆ getLine() [1/2]

int File::getLine ( char * string,
int len )

◆ getLine() [2/2]

int File::getLine ( String & string)

Gets a line from the file

Return values
stringOutput string class

References getLine().

◆ init()

int File::init ( )

Initializes the class data

References WXP::FileAttr::READ.

Referenced by File(), and open().

◆ isOpen()

◆ open() [1/3]

◆ open() [2/3]

int File::open ( const char * file,
int raccess )

Opens file with access

Parameters
fileFilename to open
raccessFile access READ, WRITE, APPEND

References WXP::FileAttr::APPEND, open(), WXP::FileAttr::READ, and WXP::FileAttr::WRITE.

◆ open() [3/3]

int File::open ( String & file,
const char * raccess )

Opens file with access

Parameters
fileFilename to open
accessFile access (r, w, a, r+, see fopen)

References WXP::String::get(), and open().

◆ printf()

int File::printf ( const char * fmt,
... )

Prints formatted data to file (see fprintf)

Parameters
fmtPrintf format to use
...Variables to format

Referenced by WXP::WmoIngest::printLog(), scanf(), and WXP::WmoIngest::sendPAN().

◆ read() [1/2]

int File::read ( unsigned char * rbuf,
int size )

Reads a set number of values from file (see fread)

Return values
rbufOutput byte buffer
Parameters
sizeNumber of bytes

◆ read() [2/2]

int File::read ( unsigned char * rbuf,
int size,
int num )

Reads a set number of values from file (see fread)

Return values
rbufOutput byte buffer
Parameters
sizeSize of each value in bytes
numNumber of values

Referenced by WXP::GridFile::checkType(), WXP::MapFile::checkType(), WXP::ImgWxpFile::open(), WXP::ImgWxpFile::readData(), WXP::GifFile::write(), and WXP::LZWComp::write().

◆ rewind()

int File::rewind ( )

Rewinds the file

◆ scanf()

int File::scanf ( const char * fmt,
... )

Scans file for data (see fscanf)

Parameters
fmtScanf format to use
Return values
...Output variables

References printf().

Referenced by WXP::KmlFile::checkType(), WXP::ProfFile::checkType(), WXP::SatCdfFile::checkType(), WXP::SfcCdfFile::checkType(), WXP::SfcXmlFile::checkType(), WXP::MapPlot::draw(), WXP::MetaPlot::draw(), and WXP::Unit::readFile().

◆ seek() [1/2]

int WXP::File::seek ( int byte)
inline

Seeks to byte position in file offset from beginning

References seek().

Referenced by seek().

◆ seek() [2/2]

int File::seek ( int byte,
int where )

Seeks to a specific location in a file

Parameters
byteOffset in file to seek to
whereWhere to offset from (0=begin, 1=current, 2=end)

◆ setShare()

int File::setShare ( int mode)

Sets the share mode for file

Parameters
mode1=shared, 0=not shared

◆ skipLine()

int File::skipLine ( )

Skips a line in the file

Referenced by WXP::Unit::readFile().

◆ tell()

int File::tell ( )

Returns the current location in file

Returns
Byte offset

◆ write() [1/2]

int File::write ( const unsigned char * rbuf,
int size )

Writes a set number of values to file (see fwrite)

Parameters
rbufInput byte buffer
sizeNumber of bytes

◆ write() [2/2]

int File::write ( const unsigned char * rbuf,
int size,
int num )

Writes a set number of values to file (see fwrite)

Parameters
rbufInput byte buffer
sizeSize of each value in bytes
numNumber of values

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