#include "stdafx.h" void Jenga::Common::FileSystem::SearchFiles( Jenga::Common::Strings &resultOfFullPath, const std::string &findStr, bool isNeedDirResults ) { // '/' → '\\' std::string tempFindStr = findStr; Jenga::Common::StringReplace( tempFindStr, "/", "\\" ); WIN32_FIND_DATA wfd; HANDLE hFind=FindFirstFile( tempFindStr.c_str(), &wfd ); Jenga::Common::Path path( tempFindStr ); std::string dirPath = path.GetDirPath(); if( !dirPath.empty() && dirPath[dirPath.size()-1] == '\\' ) { dirPath = dirPath.substr( 0, dirPath.size() - 1 ); } if( hFind != INVALID_HANDLE_VALUE ) { do { if( wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) { // ディレクトリのとき if( isNeedDirResults ) { resultOfFullPath.push_back( dirPath + "\\" + wfd.cFileName ); } } else { //ファイルのとき resultOfFullPath.push_back( dirPath + "\\" + wfd.cFileName ); } } while( FindNextFile( hFind, &wfd ) ); FindClose( hFind ); } }