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

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

ヘッダファイルを整理中

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