April 29, 2024, 10:05:08 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


CFile Class

Started by Mike Stefanik, March 16, 2006, 03:57:41 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Mike Stefanik

March 16, 2006, 03:57:41 PM Last Edit: March 16, 2006, 03:59:15 PM by Mike Stefanik
I've written the basic implementation for the CFile class that is pretty close to the one used in MFC. I realize that Aurora has some basic file handling functions, but this should make it somewhat easier to port existing code (and, in my opinion, it fits better to use objects rather than global functions). A simple example of how you'd use it:


CFile file;
dstring strBuffer[1024];
int nLength;

if (file.Open(strFileName, modeRead))
{
ÂÃ,  ÂÃ,  do
ÂÃ,  ÂÃ,  {
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  nLength = file.Read(strBuffer, 1024);
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  if (nLength > 0)
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  {
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  strBuffer[nLength] = 0;
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  writeln(strBuffer);
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  }
ÂÃ,  ÂÃ,  }
ÂÃ,  ÂÃ,  until (nLength = 0);

ÂÃ,  ÂÃ,  file.Close();
}


Every method is virtual, so while it can be used as-is, it's really designed to work as a base class for your own file handling classes.
Mike Stefanik
www.catalyst.com
Catalyst Development Corporation