階層の深いDIRを処理した時にバグがでました。なぜか最下層のDIRがファイルにみなされてしまうため、そっから変なファイルやDIRができます助けてください。お願いします。
EXPORT BOOL __stdcall CopyDir(LPSTR sSource , LPSTR sDest){
HANDLE hFind = INVALID_HANDLE_VALUE;
WIN32_FIND_DATA uFind;
char sFindPath[256],sFoundFile[256],Moto[256],Saki[256];
BOOL ret;
CreateDirectory(sDest, NULL);//フォルダを作成する
AddBackslash(sSource);//コピー元バックスラッシュ追加処理呼び出し
AddtBackslash(sDest);//コピ−先バックスラッシュ追加処理呼び出し
sprintf(sFindPath,"%s*.*",sSource);
hFind = FindFirstFile(sFindPath, &uFind);
if (hFind != INVALID_HANDLE_VALUE){
do {
strcpy(sFoundFile,uFind.cFileName);//ファイル名の取得
if ((!(strcmp(sFoundFile, "..") == 0)) && (!(strcmp(sFoundFile, ".") == 0))){
sprintf(Moto,"%s%s", sSource,sFoundFile);
sprintf(Saki,"%s%s", sDest,sFoundFile);
if (uFind.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY){
CopyDir(Moto, Saki);
}
else{ //ファイルの場合はコピーする
CopyFile(Moto, Saki, FALSE);
}
}
} while (FindNextFile(hFind, &uFind));
FindClose(hFind);
return 0;//成功
}
FindClose(hFind);
return 1;//失敗
}