| 1 | #include "stdafx.h"
|
|---|
| 2 |
|
|---|
| 3 | bool Jenga::Common::Path::IsExistFile() const
|
|---|
| 4 | {
|
|---|
| 5 | WIN32_FIND_DATA wfd;
|
|---|
| 6 | HANDLE hFind = FindFirstFile( fullPath.c_str() , &wfd );
|
|---|
| 7 | if( hFind != INVALID_HANDLE_VALUE ){
|
|---|
| 8 | FindClose( hFind );
|
|---|
| 9 | if( wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
|
|---|
| 10 | {
|
|---|
| 11 | // ディレクトリ
|
|---|
| 12 | return false;
|
|---|
| 13 | }
|
|---|
| 14 |
|
|---|
| 15 | return true;
|
|---|
| 16 | }
|
|---|
| 17 |
|
|---|
| 18 | return false;
|
|---|
| 19 | }
|
|---|
| 20 |
|
|---|
| 21 | std::string Jenga::Common::Path::MakeFullPath( const std::string &relativePath, const std::string &baseDirPath )
|
|---|
| 22 | {
|
|---|
| 23 | int i,i2,i3,i4;
|
|---|
| 24 | char temporary[MAX_PATH];
|
|---|
| 25 |
|
|---|
| 26 | char resultPath[MAX_PATH];
|
|---|
| 27 | lstrcpy( resultPath, relativePath.c_str() );
|
|---|
| 28 |
|
|---|
| 29 | // '/'→'\'
|
|---|
| 30 | for( i=0;resultPath[i];i++ ){
|
|---|
| 31 | if( resultPath[i] == '/' ){
|
|---|
| 32 | resultPath[i]='\\';
|
|---|
| 33 | }
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | if(strstr(resultPath,":")||strstr(resultPath,"\\\\")) return resultPath;
|
|---|
| 37 |
|
|---|
| 38 | i=0;i2=0;
|
|---|
| 39 | while(1){
|
|---|
| 40 | if(resultPath[i]=='.'&&resultPath[i+1]=='\\') i+=2;
|
|---|
| 41 | if(resultPath[i]=='.'&&resultPath[i+1]=='.'&&resultPath[i+2]=='\\'){
|
|---|
| 42 | i2++;
|
|---|
| 43 | i+=3;
|
|---|
| 44 | }
|
|---|
| 45 | else break;
|
|---|
| 46 | }
|
|---|
| 47 |
|
|---|
| 48 | std::string tempBaseDirPath = baseDirPath;
|
|---|
| 49 | if( tempBaseDirPath[tempBaseDirPath.size()-1] != '\\' )
|
|---|
| 50 | {
|
|---|
| 51 | tempBaseDirPath += "\\";
|
|---|
| 52 | }
|
|---|
| 53 |
|
|---|
| 54 | i3=(int)tempBaseDirPath.size();i4=0;
|
|---|
| 55 | while(i4<i2){
|
|---|
| 56 | for(i3--;;i3--){
|
|---|
| 57 | if(tempBaseDirPath[i3-1]=='\\'){
|
|---|
| 58 | i4++;
|
|---|
| 59 | break;
|
|---|
| 60 | }
|
|---|
| 61 | }
|
|---|
| 62 | }
|
|---|
| 63 | memcpy(temporary,tempBaseDirPath.c_str(),i3);
|
|---|
| 64 | temporary[i3]=0;
|
|---|
| 65 | lstrcat(temporary,resultPath+i);
|
|---|
| 66 | lstrcpy(resultPath,temporary);
|
|---|
| 67 |
|
|---|
| 68 | if( resultPath[lstrlen(resultPath)-1] == '\\' )
|
|---|
| 69 | {
|
|---|
| 70 | resultPath[lstrlen(resultPath)-1] = 0;
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
| 73 | return resultPath;
|
|---|
| 74 | }
|
|---|
| 75 | std::string Jenga::Common::Path::MakeFullPathByCurrentDirectory( const std::string &relativePath )
|
|---|
| 76 | {
|
|---|
| 77 | return MakeFullPath( relativePath, Jenga::Common::Environment::GetCurrentDir() );
|
|---|
| 78 | }
|
|---|
| 79 | std::string Jenga::Common::Path::ExtractDirPath( const std::string &filepath )
|
|---|
| 80 | {
|
|---|
| 81 | Path path( filepath );
|
|---|
| 82 | std::string result = path.GetDriveName() + path.GetDirName();
|
|---|
| 83 | return result;
|
|---|
| 84 | }
|
|---|