对C++Builder文件操作类的改进
#1?牐牫绦蛉缦拢?
?牐?<StdioFile.h>
?牐燾lass TStdioFile: public TFileStream ??
?牐爗
public:
?牐爑nsigned int ReadItem(String & Buffer);
?牐爑nsigned int WriteItem(String Buffer);??
?牐燭StdioFile(AnsiString FileName,unsigned short Mode);
?牐爙??
?牐?<StdioFile.cpp>
?牐燭StdioFile::TStdioFile(AnsiString FileName,unsigned short Mode):TFileStream(FileName,Mode)
?牐爗??
?牐爙
?牐爑nsigned int TStdioFile::ReadItem(String & Buffer)
?牐爗char * pTempBuffer = new char;
?牐燬tring Temp = "";
?牐爑nsigned short nBytesRead = 0;
?牐爑nsigned int nBytes = 0;
?牐爊BytesRead = Read(pTempBuffer,1);??
?牐爓hile (* pTempBuffer != ',' &&(Position < Size)) ??
?牐燭emp += * pTempBuffer;
?牐爊BytesRead = Read(pTempBuffer,1);??
?牐爊Bytes++;
?牐爙;??
?牐爄f (Position == Size) Temp += * pTempBuffer;
?牐燘uffer=Temp;
?牐爎eturn(nBytes);??
?牐爙
?牐爑nsigned int TStdioFile::WriteItem(String Buffer)
?牐爗char * pTempBuffer;
?牐爑nsigned int nBytes = 0;
?牐爁or (pTempBuffer = Buffer.c_str();*pTempBuffer != NULL; pTempBuffer++){
?牐燱rite(pTempBuffer,1);??
?牐爊Bytes++;
?牐爙;
?牐?* pTempBuffer = 44;
?牐燱rite(pTempBuffer,1);??
?牐爎eturn(nBytes);
}