Rev | Line | |
---|
[518] | 1 | #include "stdafx.h"
|
---|
[166] | 2 |
|
---|
| 3 | using namespace std;
|
---|
| 4 | using namespace Jenga::Common;
|
---|
| 5 |
|
---|
[295] | 6 | Directory::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 |
|
---|
[166] | 18 | string 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.