#include "stdafx.h" using namespace Jenga::Common; Directory::Directory( const std::string &path, bool isMake ) : path( path ) { if ( isMake ) { if (!::MakeSureDirectoryPathExists(path.c_str())) { Jenga::Throw( "MakeSureDirectoryPathExists failed!" ); } } } Directory::Directory( const Directory &dir ) : path( dir.path ) { } std::string Directory::GetFullPath( const std::string &relationPath ) const { std::string resultPath = relationPath; // '/'→'\' BOOST_FOREACH( char &c, resultPath ) { if( c == '/' ) { c = '\\'; } } if( resultPath.find( ":" ) != std::string::npos || resultPath.find( "\\\\" ) != std::string::npos ) { // フルパスが引き渡されていたとき return resultPath; } int i=0,i2=0; while(1){ if(resultPath[i]=='.'&&resultPath[i+1]=='\\') i+=2; if(resultPath[i]=='.'&&resultPath[i+1]=='.'&&resultPath[i+2]=='\\'){ i2++; i+=3; } else break; } int i3 = (int)path.size(),i4=0; while(i4path + "\\" + findStr ).c_str(), &wfd ); if( hFind != INVALID_HANDLE_VALUE ) { do { if( wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) { // ディレクトリのとき if( isRecuresive ) { Directory tempDir( this->path + "\\" + wfd.cFileName ); tempDir.SearchFiles( resultOfFullPath, findStr, isRecuresive ); } } else { //ファイルのとき resultOfFullPath.push_back( this->path + "\\" + wfd.cFileName ); } } while( FindNextFile( hFind, &wfd ) ); FindClose( hFind ); } }