source: dev/trunk/ab5.0/jenga/src/common/Path.cpp@ 467

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

いくつかのグローバル変数をProgram/Debuggerクラスにまとめた。

File size: 1.3 KB
Line 
1#include <boost/foreach.hpp>
2#include <jenga/include/common/Path.h>
3
4#include <windows.h>
5
6
7bool Jenga::Common::Path::IsExistFile() const
8{
9 WIN32_FIND_DATA wfd;
10 HANDLE hFind = FindFirstFile( fullPath.c_str() , &wfd );
11 if( hFind != INVALID_HANDLE_VALUE ){
12 FindClose( hFind );
13 if( wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
14 {
15 // ディレクトリ
16 return false;
17 }
18
19 return true;
20 }
21
22 return false;
23}
24
25std::string Jenga::Common::Path::MakeFullPath( const std::string &relativePath, const std::string &baseDirPath )
26{
27 int i,i2,i3,i4;
28 char temporary[MAX_PATH];
29
30 char resultPath[MAX_PATH];
31 lstrcpy( resultPath, relativePath.c_str() );
32
33 // '/'→'\'
34 for( i=0;resultPath[i];i++ ){
35 if( resultPath[i] == '/' ){
36 resultPath[i]='\\';
37 }
38 }
39
40 if(strstr(resultPath,":")||strstr(resultPath,"\\\\")) return resultPath;
41
42 i=0;i2=0;
43 while(1){
44 if(resultPath[i]=='.'&&resultPath[i+1]=='\\') i+=2;
45 if(resultPath[i]=='.'&&resultPath[i+1]=='.'&&resultPath[i+2]=='\\'){
46 i2++;
47 i+=3;
48 }
49 else break;
50 }
51
52 i3=(int)baseDirPath.size();i4=0;
53 while(i4<i2){
54 for(i3--;;i3--){
55 if(baseDirPath[i3-1]=='\\'){
56 i4++;
57 break;
58 }
59 }
60 }
61 memcpy(temporary,baseDirPath.c_str(),i3);
62 temporary[i3]=0;
63 lstrcat(temporary,resultPath+i);
64 lstrcpy(resultPath,temporary);
65
66 return resultPath;
67}
Note: See TracBrowser for help on using the repository browser.