struct MyUeniFile
{
int type;
std::string name;
std::string path;
std::string cPath;
};
void cFileCtrl::getDirFile(const char* dirPath)
{
char pathBuf[256];
sprintf( pathBuf, "%s//*.*", dirPath);
WIN32_FIND_DATA findFile;
HANDLE nHandle = ::FindFirstFile( pathBuf, &findFile );
do
{
if( nHandle == (HANDLE)0xffffffff)
break;
else
{
string fileName = findFile.cFileName;
char fulPath[256] = {0};
sprintf(fulPath, "%s//%s", dirPath, fileName.c_str());
fileName = fulPath;
MyUeniFile tmpUeni;
tmpUeni.name = findFile.cFileName;
tmpUeni.path = fulPath;
tmpUeni.cPath = fulPath;
int pointIndex = fileName.find('.');
if( pointIndex == -1)
{
string newWp = fulPath;
getDirFile(newWp.c_str());
continue;
}
string strType = fileName.substr( pointIndex, fileName.length());
if( strType == ".lua" )
{
tmpUeni.type = 0;
allFileName.push_back(tmpUeni);
}
if( strType == ".xml" )
{
tmpUeni.type = 1;
allFileName.push_back(tmpUeni);
}
if( strType == ".txt" )
{
tmpUeni.type = 2;
allFileName.push_back(tmpUeni);
}
}
}
while(::FindNextFile(nHandle, &findFile));
::FindClose(nHandle);
}