| 1 |
#include "StdAfx.h" |
|---|
| 2 |
#include "imports_class.h" |
|---|
| 3 |
#include "filefuncs.h" |
|---|
| 4 |
|
|---|
| 5 |
bool ImportClass::isFile(const string& root, string& returnFile) |
|---|
| 6 |
{ |
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
string importPath = root.substr(0,root.find_last_of("\\")) ; |
|---|
| 11 |
unsigned long pos = importPath .find_last_of("\\"); |
|---|
| 12 |
string fileName ; |
|---|
| 13 |
if ( pos != string::npos ) |
|---|
| 14 |
{ |
|---|
| 15 |
fileName = importPath.substr(pos ); |
|---|
| 16 |
} |
|---|
| 17 |
|
|---|
| 18 |
importPath = importPath .substr(0,importPath .find_last_of("\\")) ; |
|---|
| 19 |
importPath += "\\"; |
|---|
| 20 |
|
|---|
| 21 |
// AfxMessageBox("in isFile"); |
|---|
| 22 |
// AfxMessageBox(importPath.c_str()); |
|---|
| 23 |
|
|---|
| 24 |
int i = 0; |
|---|
| 25 |
for ( i = 0 ;i < allDirs.size(); i++ ) |
|---|
| 26 |
{ |
|---|
| 27 |
|
|---|
| 28 |
string dir = allDirs[i]; |
|---|
| 29 |
|
|---|
| 30 |
if ( dir.length() > importPath.length() ) |
|---|
| 31 |
{ |
|---|
| 32 |
// AfxMessageBox(dir.c_str()); |
|---|
| 33 |
// MessageBox(0,dir.substr(dir.length() - importPath.length() ).c_str() ,"TITLE",0 ); |
|---|
| 34 |
if ( dir.substr(dir.length() - importPath.length()) == importPath ) |
|---|
| 35 |
{ |
|---|
| 36 |
|
|---|
| 37 |
returnFile = allDirs[i] + fileName + ".d" ; |
|---|
| 38 |
return true; |
|---|
| 39 |
} |
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
} |
|---|
| 43 |
|
|---|
| 44 |
} |
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
return false; |
|---|
| 50 |
} |
|---|
| 51 |
|
|---|
| 52 |
vector<string> ImportClass::search(const string& _importPath) |
|---|
| 53 |
{ |
|---|
| 54 |
vector<string> results; |
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
string importPath = _importPath; |
|---|
| 58 |
|
|---|
| 59 |
// if ( importPath[importPath.length() - 1] == '\\' ) |
|---|
| 60 |
// { |
|---|
| 61 |
// importPath = importPath.substr(0,importPath.length() - 1); |
|---|
| 62 |
// } |
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 |
// AfxMessageBox(importPath.c_str()); |
|---|
| 66 |
int i = 0; |
|---|
| 67 |
for ( i = 0 ;i < allDirs.size(); i++ ) |
|---|
| 68 |
{ |
|---|
| 69 |
|
|---|
| 70 |
string dir = allDirs[i]; |
|---|
| 71 |
|
|---|
| 72 |
if ( dir.length() > importPath.length() ) |
|---|
| 73 |
{ |
|---|
| 74 |
// AfxMessageBox(dir.c_str()); |
|---|
| 75 |
// MessageBox(0,dir.substr(dir.length() - importPath.length() ).c_str() ,"TITLE",0 ); |
|---|
| 76 |
if ( dir.substr(dir.length() - importPath.length()) == importPath ) |
|---|
| 77 |
{ |
|---|
| 78 |
|
|---|
| 79 |
//AfxMessageBox(allDirs[i].c_str() ); |
|---|
| 80 |
readImportDirContents(allDirs[i],results ); |
|---|
| 81 |
break; |
|---|
| 82 |
} |
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 |
} |
|---|
| 86 |
|
|---|
| 87 |
} |
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 |
return results; |
|---|
| 92 |
} |
|---|
| 93 |
|
|---|
| 94 |
vector<string> ImportClass::initalImports() |
|---|
| 95 |
{ |
|---|
| 96 |
vector<string> files; |
|---|
| 97 |
for ( int i = 0 ; i < baseDirs.size(); i++ ) |
|---|
| 98 |
{ |
|---|
| 99 |
//AfxMessageBox(baseDirs[i].c_str() ); |
|---|
| 100 |
readImportDirContents(baseDirs[i],files); |
|---|
| 101 |
} |
|---|
| 102 |
|
|---|
| 103 |
//readImportDirContents(".",files); |
|---|
| 104 |
|
|---|
| 105 |
return files; |
|---|
| 106 |
} |
|---|
| 107 |
|
|---|
| 108 |
bool ImportClass::getFullPath(const string& importPath, string& path) |
|---|
| 109 |
{ |
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
vector<string> results; |
|---|
| 113 |
|
|---|
| 114 |
int i = 0 ; |
|---|
| 115 |
|
|---|
| 116 |
for ( i = 0 ; i < baseDirs.size(); i++) |
|---|
| 117 |
{ |
|---|
| 118 |
|
|---|
| 119 |
string dir = baseDirs[i]; |
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 |
//AfxMessageBox(dir.c_str()); |
|---|
| 123 |
//MessageBox(0,dir.substr(dir.length() - importPath.length() ).c_str() ,"TITLE",0 ); |
|---|
| 124 |
|
|---|
| 125 |
//AfxMessageBox(allDirs[i].c_str() ); |
|---|
| 126 |
readImportDirContents(dir,results ); |
|---|
| 127 |
|
|---|
| 128 |
for ( int j = 0 ; j < results.size();j++) |
|---|
| 129 |
{ |
|---|
| 130 |
|
|---|
| 131 |
string fullPath = dir + "\\" + results[j]; |
|---|
| 132 |
|
|---|
| 133 |
//i MessageBox(0,fullPath.substr(fullPath.length() - importPath.length() ).c_str(), "TUT",0 ); |
|---|
| 134 |
if ( fullPath.length() > importPath.length()) |
|---|
| 135 |
{ |
|---|
| 136 |
|
|---|
| 137 |
if ( fullPath.substr(fullPath.length() - importPath.length() ) == importPath ) |
|---|
| 138 |
{ |
|---|
| 139 |
// AfxMessageBox(fullPath.c_str()); |
|---|
| 140 |
path = fullPath + ".d"; |
|---|
| 141 |
return true; |
|---|
| 142 |
} |
|---|
| 143 |
|
|---|
| 144 |
} |
|---|
| 145 |
} |
|---|
| 146 |
|
|---|
| 147 |
|
|---|
| 148 |
results.clear(); |
|---|
| 149 |
|
|---|
| 150 |
|
|---|
| 151 |
|
|---|
| 152 |
|
|---|
| 153 |
|
|---|
| 154 |
|
|---|
| 155 |
} |
|---|
| 156 |
|
|---|
| 157 |
|
|---|
| 158 |
for ( i = 0 ;i < allDirs.size(); i++ ) |
|---|
| 159 |
{ |
|---|
| 160 |
|
|---|
| 161 |
string dir = allDirs[i]; |
|---|
| 162 |
|
|---|
| 163 |
//AfxMessageBox(dir.c_str()); |
|---|
| 164 |
//MessageBox(0,dir.substr(dir.length() - importPath.length() ).c_str() ,"TITLE",0 ); |
|---|
| 165 |
|
|---|
| 166 |
//AfxMessageBox(allDirs[i].c_str() ); |
|---|
| 167 |
readImportDirContents(dir,results ); |
|---|
| 168 |
|
|---|
| 169 |
for ( int j = 0 ; j < results.size();j++) |
|---|
| 170 |
{ |
|---|
| 171 |
|
|---|
| 172 |
string fullPath = dir + results[j]; |
|---|
| 173 |
|
|---|
| 174 |
// MessageBox(0,fullPath.substr(fullPath.length() - importPath.length() ).c_str(), "TITLE",0 ); |
|---|
| 175 |
|
|---|
| 176 |
if ( fullPath.length() > importPath.length()) |
|---|
| 177 |
{ |
|---|
| 178 |
|
|---|
| 179 |
if ( fullPath.substr(fullPath.length() - importPath.length() ) == importPath ) |
|---|
| 180 |
{ |
|---|
| 181 |
//AfxMessageBox(fullPath.c_str()); |
|---|
| 182 |
path = fullPath + ".d"; |
|---|
| 183 |
return true; |
|---|
| 184 |
} |
|---|
| 185 |
|
|---|
| 186 |
} |
|---|
| 187 |
} |
|---|
| 188 |
|
|---|
| 189 |
|
|---|
| 190 |
results.clear(); |
|---|
| 191 |
|
|---|
| 192 |
|
|---|
| 193 |
|
|---|
| 194 |
|
|---|
| 195 |
|
|---|
| 196 |
} |
|---|
| 197 |
|
|---|
| 198 |
|
|---|
| 199 |
return false; |
|---|
| 200 |
|
|---|
| 201 |
|
|---|
| 202 |
} |
|---|