tstring GetAlternatePathName(LPCTSTR lpStrPath)
{
TCHAR szFullPath[MAX_PATH] = {0};
int mm = lstrlen(lpStrPath);
if (lpStrPath[lstrlen(lpStrPath)-1] != '/ ' || lpStrPath[lstrlen(lpStrPath)-1] != '\\ ') {
TCHAR* pTemp = (TCHAR*)lpStrPath;
pTemp[lstrlen(lpStrPath)] = '\\';
}
for (int i = 0; i< lstrlen(lpStrPath); i++){
if (lpStrPath[i] == '/' || lpStrPath[i] == '\\') {
WIN32_FIND_DATA FindFileData;
tstring strTemp = lpStrPath;
strTemp = strTemp.substr(0, i);
HANDLE hFind=::FindFirstFile(strTemp.c_str(), &FindFileData);
if(INVALID_HANDLE_VALUE == hFind) {
continue;
}
do{
if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY
&& !(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DEVICE)) {
tstring strPath = szFullPath;
if (strTemp.length()<= 8) {
PathCombine(szFullPath, strPath.c_str(), strTemp.c_str());
}
else {
PathCombine(szFullPath, strPath.c_str(), FindFileData.cAlternateFileName);
}
}
}while(::FindNextFile(hFind,&FindFileData));
::FindClose(hFind);
}
}
return szFullPath;
}
{
TCHAR szFullPath[MAX_PATH] = {0};
int mm = lstrlen(lpStrPath);
if (lpStrPath[lstrlen(lpStrPath)-1] != '/ ' || lpStrPath[lstrlen(lpStrPath)-1] != '\\ ') {
TCHAR* pTemp = (TCHAR*)lpStrPath;
pTemp[lstrlen(lpStrPath)] = '\\';
}
for (int i = 0; i< lstrlen(lpStrPath); i++){
if (lpStrPath[i] == '/' || lpStrPath[i] == '\\') {
WIN32_FIND_DATA FindFileData;
tstring strTemp = lpStrPath;
strTemp = strTemp.substr(0, i);
HANDLE hFind=::FindFirstFile(strTemp.c_str(), &FindFileData);
if(INVALID_HANDLE_VALUE == hFind) {
continue;
}
do{
if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY
&& !(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DEVICE)) {
tstring strPath = szFullPath;
if (strTemp.length()<= 8) {
PathCombine(szFullPath, strPath.c_str(), strTemp.c_str());
}
else {
PathCombine(szFullPath, strPath.c_str(), FindFileData.cAlternateFileName);
}
}
}while(::FindNextFile(hFind,&FindFileData));
::FindClose(hFind);
}
}
return szFullPath;
}