Changeset 620 in dev for trunk/ab5.0/jenga/src/common/Directory.cpp
- Timestamp:
- May 19, 2008, 6:17:02 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ab5.0/jenga/src/common/Directory.cpp
r523 r620 14 14 } 15 15 } 16 Directory::Directory( const Directory &dir ) 17 : path( dir.path ) 18 { 19 } 16 20 17 std::string Directory::GetFullPath( const std::string &relationPath ) 21 std::string Directory::GetFullPath( const std::string &relationPath ) const 18 22 { 19 23 std::string resultPath = relationPath; … … 61 65 return temporary; 62 66 } 67 68 void _GetRelationalPath(char *path,const char *dir){ 69 //相対パスを取得 70 int i,i2,i3,i4,i5; 71 char temporary[MAX_PATH],temp2[MAX_PATH],temp3[MAX_PATH],temp4[MAX_PATH]; 72 73 //ドライブ名をチェック 74 _splitpath(path,temporary,0,0,0); 75 _splitpath(dir,temp2,0,0,0); 76 if(lstrcmpi(temporary,temp2)!=0) return; 77 78 _splitpath(path,0,temporary,0,0); 79 _splitpath(dir,0,temp2,0,0); 80 i=1;i2=1; 81 while(1){ 82 i4=i; 83 if(temporary[i-1]=='\\'&&temporary[i]){ //path側 84 for(i3=0;;i++,i3++){ 85 if(temporary[i]=='\\'){ 86 temp3[i3]=0; 87 i++; 88 break; 89 } 90 temp3[i3]=temporary[i]; 91 } 92 } 93 else temp3[0]=0; 94 95 i5=i2; 96 if(temp2[i2-1]=='\\'&&temp2[i2]){ //dir側 97 for(i3=0;;i2++,i3++){ 98 if(temp2[i2]=='\\'){ 99 temp4[i3]=0; 100 i2++; 101 break; 102 } 103 temp4[i3]=temp2[i2]; 104 } 105 } 106 else temp4[0]=0; 107 108 if(temp3[0]=='\0'&&temp4[0]=='\0'){ 109 lstrcpy(temp3,".\\"); 110 break; 111 } 112 113 if(lstrcmpi(temp3,temp4)!=0){ 114 for(i3=0;;i5++){ 115 if(temp2[i5]=='\0') break; 116 if(temp2[i5]=='\\') i3++; 117 } 118 if(i3==0) lstrcpy(temp3,".\\"); 119 else{ 120 temp3[0]=0; 121 for(i2=0;i2<i3;i2++) lstrcat(temp3,"..\\"); 122 } 123 lstrcat(temp3,temporary+i4); 124 break; 125 } 126 } 127 _splitpath(path,0,0,temporary,temp2); 128 lstrcat(temp3,temporary); 129 lstrcat(temp3,temp2); 130 lstrcpy(path,temp3); 131 } 132 133 std::string Directory::GetRelationalPath( const std::string &fullPath ) const 134 { 135 char temp[1024]; 136 lstrcpy( temp, fullPath.c_str() ); 137 _GetRelationalPath( temp, path.c_str() ); 138 return temp; 139 }
Note:
See TracChangeset
for help on using the changeset viewer.