_sntprintf(wildFileName, MY_MAX_PATH, _T("%s\\%s"),
dir, strFileName);
handle = FindFirstFile(wildFileName, &ffd);
if (handle==INVALID_HANDLE_VALUE)
{
_tprintf(_T("findfirst failed of
error code =%d\n"), GetLastError());
return 0;
}
do
{
if (_tcsicmp(ffd.cFileName,
_T("."))!=0 && _tcsicmp(ffd.cFileName, _T(".."))!=0)
{
_stprintf(curFileName, _T("%s\\%s"), dir, ffd.cFileName);
if
(GetFileAttributes(curFileName)&FILE_ATTRIBUTE_DIRECTORY)
{
// filter my personal folder
if (_tcsicmp(ffd.cFileName, _T("personal")) !=0)
{
genericFind(curFileName,
handleFileCallBack, filter, pUser);
}
}
else
{
if (!handleFileCallBack(curFileName, ffd.cFileName,
pUser))
{
break;
}
else
{
nCounter ++;
}
}
}
}
while (FindNextFile(handle,
&ffd));
FindClose(handle);
return nCounter;
}
int _tmain(int argc, LPTSTR* argv)
{
//I:\MyWeb\diabloforum mylist.htm
if (argc == 3)
{
createList(argv[1], argv[2]);
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// This is the latest version by using boost as there are some nasty thing about language encoding problem with windows
// api. It is said, in windows, you should always use wide-char api and widestring, but in linux, you should almost never
// use wide char. Till now, I don't really understand this but it works.
string comment1="This is a list of all files in this website and to
make it easy for searching, the they are sorted by file name"
" and here is <a href=\"";
string comment2="/myListTool.html\"> the source code </a> of file how it is generated.";
string tableHeader1="<table border=\"1\" cellpadding=\"5\" cellspacing=\"5\" width=\"100%\">";
string tableHeader2="<tr> <th> file index </th>
<th> file name </th> </tr>";
string bottom="</table></body></html>";
switch (str[i])
{
case '-':
case '_':
case '.':
case '!':
case '~':
case '*':
case '\'':
case '(':
case ')':
case '"':
result += str[i];
break;
default:
ch = (str[i] & MASK1) >> 4;
result += '%';
void showString(const string& str)
{
for (int i = 0; i < str.size(); i ++)
{
unsigned char ch = str[i];
cout<<ch;
//cout.flush();
}
}
void showMap(const StringMap& stringMap)
{
cout<<header1<<header2<<header3<<endl;
cout<<tableHeader1<<tableHeader2<<endl;
cout<<comment1<<prefix<<comment2<<endl;
int counter = 1;
for (StringMap::const_iterator it = stringMap.begin(); it != stringMap.end(); it ++)
{
cout << tableColumn1 << counter << tableColumn2;
showString(it->second);
cout << tableColumn3;
showString(it->first);
cout << tableColumn4;
counter ++;
}
cout<< bottom<<endl;
}
int main()
{
path srcPath("/media/unused/diabloforum");
//path srcPath("/media/unused/diabloforum/DC/HWBooks/Serial Communications Dev guide");
//path srcPath("/media/unused/USB Design By Example");