再帰法を使っている部分のソースを記載します。
char 配列とか、一切使わずに作ってしまいました。。。
あと、適当に王道とかいってすいません。(汗
さきほどは、たとえとして
deque<std::string>
といいましたが、
実際は、
deque<musicFIle>
struct musicFile{
std::string filePath;
std::string title;
int soundHandle;
};
このようになってます。
deque<musicFile> searchFolder(string folderName,bool subFol){
deque<musicFile> tempReturnList;
//初期化
HANDLE hFind;
WIN32_FIND_DATA FileData;
//見つかったファイル名をいれる。
deque<string> foundThese;
deque<string> subFolders;
string folderFindPath = folderName;
folderFindPath += "/*";
hFind = FindFirstFile((LPCTSTR)folderFindPath.c_str(), &FileData);
if(hFind == INVALID_HANDLE_VALUE) {
FindClose(hFind);
MessageBeep(MB_ICONHAND);
printfDx("No file found");
}
do{
if(strcmp((const char *)FileData.cFileName,".") != 0 &&
strcmp((const char *)FileData.cFileName,"..") != 0 ){
string toAdd = (string)(const char *)FileData.cFileName;
if(toAdd.length() > 4 && toAdd.find(".wav") == toAdd.length() - 4)
foundThese.push_back(toAdd);
else if(subFol && toAdd.find(".") == string.npos)
subFolders.push_back(toAdd);
}
}while(FindNextFile(hFind, &FileData));
FindClose(hFind);
for each(string temp in foundThese){
musicFile tempSong;
tempSong.filePath = (folderName + "\\") + temp;
tempSong.soundHandle = 0;
tempSong.title = temp;
tempReturnList.push_back(tempSong);
}
if(subFol){
for each(string tempSubFolder in subFolders){
string subFolPath = (folderName + "\\") + tempSubFolder;
deque<musicFile> bigList = searchFolder(subFolPath,true);
for each(musicFile tempMusicFile in bigList){
tempReturnList.push_back(tempMusicFile);
}
}
}
return tempReturnList;
}
あと、エラーが発生する(アクセス違反が発生する)のは
xmemoryファイルの
_STD_BEGIN
// TEMPLATE FUNCTION _Allocate
template<class _Ty> inline
_Ty _FARQ *_Allocate(_SIZT _Count, _Ty _FARQ *)
{ // check for integer overflow
if (_Count <= 0)
_Count = 0;
else if (((_SIZT)(-1) / _Count) < sizeof (_Ty))
_THROW_NCEE(std::bad_alloc, NULL);
// allocate storage for _Count elements of type _Ty
return ((_Ty _FARQ *)::operator new(_Count * sizeof (_Ty)));
}
と記載されている部分の、return の部分で緑矢印が表示されて止まる感じです。
(_Count = 304 でした。)
自分で思うところといえば、欲張って構造体で再帰法しないほうがよかったかな。。。ってぐらいです。
具体的なエラー内容が正確に把握できていないので、そちらの把握も手伝っていただけると幸いです。
