source: dev/trunk/ab5.0/jenga/src/common/Directory.cpp@ 518

Last change on this file since 518 was 518, checked in by dai_9181, 16 years ago

jengaプロジェクトにプリコンパイル済みヘッダを適用した。

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