source: dev/trunk/jenga/src/common/Directory.cpp@ 181

Last change on this file since 181 was 166, checked in by dai_9181, 17 years ago

Directoryクラスを追加

File size: 990 bytes
Line 
1#include <boost/foreach.hpp>
2#include <jenga/include/common/Directory.h>
3
4using namespace std;
5using namespace Jenga::Common;
6
7string Directory::GetFullPath( const string &relationPath )
8{
9 string resultPath = relationPath;
10
11 // '/'→'\'
12 BOOST_FOREACH( char &c, resultPath )
13 {
14 if( c == '/' )
15 {
16 c = '\\';
17 }
18 }
19
20 if( resultPath.find( ":" ) != string::npos || resultPath.find( "\\\\" ) != string::npos )
21 {
22 // フルパスが引き渡されていたとき
23 return resultPath;
24 }
25
26 int i=0,i2=0;
27 while(1){
28 if(resultPath[i]=='.'&&resultPath[i+1]=='\\') i+=2;
29 if(resultPath[i]=='.'&&resultPath[i+1]=='.'&&resultPath[i+2]=='\\'){
30 i2++;
31 i+=3;
32 }
33 else break;
34 }
35
36 int i3 = (int)path.size(),i4=0;
37 while(i4<i2){
38 for(i3--;;i3--){
39 if(path[i3-1]=='\\'){
40 i4++;
41 break;
42 }
43 }
44 }
45
46 char temporary[MAX_PATH];
47 memcpy(temporary,path.c_str(),i3);
48 temporary[i3]=0;
49 lstrcat(temporary,resultPath.c_str()+i);
50
51 return temporary;
52}
Note: See TracBrowser for help on using the repository browser.