wiki:Docs/Prog/Manual/ApplicationLibraries/lib825ev/File/CFile

Version 5 (modified by Don Wilson, 14 years ago) ( diff )

--

CFile

CFile is a C++ class that is provided to simplify 825 file operations. CFile is a wrapper class around the standard C library FILE object. CFile also provides some useful features such as baud rate setting for the 825 serial ports.

Constructors

  • CFile(void);
  • CFile(const string& strFilename);
  • CFile(const char* pszfilename);

These constructors just create a CFile object without opening a file.

  • CFile(const string& strFilename, const string& strMode);
  • CFile(const string& strFilename, const char* pszMode);
  • CFile(const char* pszFilename, const string& strMode);
  • CFile(const char* pszFilename, const char* pszMode);

These constructors construct the file object and attempt to open the file.

CFile fileLog("/mnt/fl1/log.txt", "a");
if(fileLog.IsOpen())
{
     fileLog.Print("Gross %s Tare %s Net %s\r\n", FormatGrossWt(1).c_str(), FormatTareWt(1).c_str(), FormatNetWt(1).c_str()); 
     fileLog.Close();
}

Member Functions

Open

Opens a specified file, or using the filename already stored in the object.

  • bool Open(const string& strFilename, const string& strMode);
  • bool Open(const string& strFilename, const char* pszMode);
  • bool Open(const char* pszFilename, const string& strMode);
  • bool Open(const char* pszFilename, const char* pszMode);
  • bool Open(const char* pszMode);

Parameters

  • strFilename - filename
  • pszFilename - filename
  • strMode - mode
  • pszMode - mode

Return

Returns true if successful or false if unsuccessful.

Close

Closes the file

  • void Close(void);

Parameters

Function does not accept any parameters

Result

Function does not return any result.

SetSerial

  • bool SetSerial(baud_index baud, data_bit_index = data8, parity_index = parityNone, stop_bit_index = stopOne);

ReadLine

DeleteFile

IsReady

SetRTS

  • bool SetRTS(bool on = true);

GetFile

Print

  • void Print(const std::string& fmt, ...);
  • void Print(const char * fmt, va_list& args);
  • void Print(const std::string& fmt, va_list& args);
  • void Print(const char * fmt, va_list& args);

SetNonBlocking

Read

  • bool Read(void * ptr, size_t size);

Write

  • bool Write(void * buf, size_t size);

GetBytesRead

GetbytesWritten

Seek

  • bool Seek(long int offset, long int origin = SEEK_SET);
Note: See TracWiki for help on using the wiki.