IonicWind Software

Aurora Compiler => Software Projects => Topic started by: Mike Stefanik on March 16, 2006, 03:57:41 PM

Title: CFile Class
Post by: Mike Stefanik on March 16, 2006, 03:57:41 PM
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.