Searching for byte sequence
I have a ListBox with a list of files in the c:\data\ folder with the
extension .dat
Now that I have the file coppied into buffer how do I search through the
buffer
for a specific sequence of bytes?
Thanks,
Ed
void CMyApp::OnSelchangeList()
{
CString mess;
CString JobFile;
char cSelect[50];
int Length;
int nSelect;
CByteArray buffer;
CFile in;
nSelect=SendDlgItemMessage(IDC_LIST, LB_GETCURSEL, 0, 0L);
DlgDirSelect((LPSTR) cSelect, IDC_LIST);
Length=strlen(cSelect);
if (cSelect[Length-1]==0x2e)
cSelect[Length-1]=0;
JobFile = _T("c:\\data\\");
JobFile += cSelect;
JobFile += ".dat";
mess = "Would you like to load ";
mess += cSelect;
mess += " as top ?";
int a = MessageBox (mess, "Query", MB_ICONINFORMATION|MB_YESNO);
if (a==IDNO) return;
if(!in.Open(JobFile, CFile::modeRead)){
DWORD err = ::GetLastError();
CString msg;
msg.Format(_T("Error opening file: %d"), err);
AfxMessageBox(msg);
return;
}
buffer.SetSize(in.GetLength());
if((INT_PTR)in.Read(buffer.GetData(), buffer.GetSize()) !=
buffer.GetSize()){
DWORD err = ::GetLastError();
CString msg;
msg.Format(_T("Error reading file: %d"), err);
AfxMessageBox(msg);
return;
}
in.Close();
}