You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
93 lines
1.9 KiB
C++
93 lines
1.9 KiB
C++
#include "stdafx.h"
|
|
#include "CrcMaker.h"
|
|
#include "CrcMakerDlg.h"
|
|
#include "crcmakerdlg.h"
|
|
#include "sfind.h"
|
|
#include "crc32.h"
|
|
|
|
class CProcessDirectory : public sys_CThread
|
|
{
|
|
|
|
CProcessDirectory(const char *dirpath, CCrcMakerDlg &Dlg) : m_dlg(Dlg)
|
|
{
|
|
m_dirpath = dirpath;
|
|
}
|
|
virtual int Main();
|
|
|
|
CString m_dirpath;
|
|
CCrcMakerDlg &m_dlg;
|
|
};
|
|
|
|
CProcessDirectory::Main()
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
** Recursivly scans the directory and create a crc checksum list
|
|
*/
|
|
void CCrcMakerDlg::ProcessDirectory( const char *dPath )
|
|
{
|
|
CWaitCursor cw;
|
|
|
|
char dirpath[256];
|
|
strcpy(dirpath,dPath);
|
|
int l = strlen(dirpath);
|
|
if( l > 0 ){
|
|
if( dirpath[l-1] == '/' ||
|
|
dirpath[l-1] == '\\' )
|
|
dirpath[l-1] = 0;
|
|
}
|
|
|
|
|
|
SFind Find("*.*", (char*)dirpath);
|
|
|
|
m_list.AddString( CString("Processing directory ")+dirpath);
|
|
|
|
CStdioFile crcSaveFile( CString(dirpath)+"\\crcfilelist.txt", CFile::modeWrite|CFile::modeCreate);
|
|
|
|
int cnt=0;
|
|
while (Find.Found()){
|
|
if( Find.IsFolder() ){
|
|
//ProcessSubDirectory();
|
|
}
|
|
else
|
|
{
|
|
//Thumbs.db ignorieren
|
|
if( 0 == stricmp(Find.JustFileName(), "Thumbs.db") )
|
|
{
|
|
CString msg;
|
|
msg.Format("Ignoring %s",Find.FileName());
|
|
m_list.AddString(msg);
|
|
continue;
|
|
}
|
|
|
|
CString crc;
|
|
int size;
|
|
crc.Format("%x", CRC32::GetFileCRC(Find.JustFileName(),(char*)dirpath,&size) );
|
|
|
|
CString crcstring;
|
|
crcstring.Format("%s %s %d", Find.JustFileName(), crc, size );
|
|
crcSaveFile.WriteString(crcstring);
|
|
crcSaveFile.Write("\n",1);
|
|
|
|
crcstring.Format("%d",size);
|
|
|
|
//listctrl anzeige
|
|
m_listctrl.InsertItem( LVIF_TEXT, cnt, "", 0 , 0, 0, 0 );
|
|
m_listctrl.SetItemText( cnt, 0, Find.JustFileName());
|
|
m_listctrl.SetItemText( cnt, 1, crc );
|
|
m_listctrl.SetItemText( cnt, 2, crcstring );
|
|
|
|
cnt++;
|
|
}
|
|
}
|
|
|
|
CString msg;
|
|
msg.Format("Saved %d crc entries to %s",cnt,crcSaveFile.GetFileName());
|
|
m_list.AddString(msg);
|
|
crcSaveFile.Close();
|
|
}
|