source: dev/trunk/ab5.0/jenga/src/common/FileSystem.cpp@ 749

Last change on this file since 749 was 749, checked in by dai, 16 years ago

「フォルダを開く」コマンドで、ファイル選択を可能にした。

File size: 1022 bytes
Line 
1#include "stdafx.h"
2
3void Jenga::Common::FileSystem::SearchFiles( Jenga::Common::Strings &resultOfFullPath, const std::string &findStr, bool isNeedDirResults )
4{
5 // '/' → '\\'
6 std::string tempFindStr = findStr;
7 Jenga::Common::StringReplace( tempFindStr, "/", "\\" );
8
9 WIN32_FIND_DATA wfd;
10 HANDLE hFind=FindFirstFile( tempFindStr.c_str(), &wfd );
11
12 Jenga::Common::Path path( tempFindStr );
13 std::string dirPath = path.GetDirPath();
14 if( !dirPath.empty() && dirPath[dirPath.size()-1] == '\\' )
15 {
16 dirPath = dirPath.substr( 0, dirPath.size() - 1 );
17 }
18
19 if( hFind != INVALID_HANDLE_VALUE )
20 {
21 do
22 {
23 if( wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
24 {
25 // ディレクトリのとき
26 if( isNeedDirResults )
27 {
28 resultOfFullPath.push_back( dirPath + "\\" + wfd.cFileName );
29 }
30 }
31 else
32 {
33 //ファイルのとき
34 resultOfFullPath.push_back( dirPath + "\\" + wfd.cFileName );
35 }
36 } while( FindNextFile( hFind, &wfd ) );
37
38 FindClose( hFind );
39 }
40}
Note: See TracBrowser for help on using the repository browser.