std::string Path::getFullPath() const { std::string out = getFolderPath(); std::string file = m_File.getFile(); if (out.size() > 0 && file.size() > 0) out += GetDirSeperator(); out += file; return out; }
void SourceFileInfo::processInclude(std::string absolutePath) { // Dont want to reprocess file if already in list for(int i = 0; i < dependencies.size(); i++) { if(absolutePath == dependencies.at(i)->getAbsolutePath()) { return; } } // Dont add initial cpp unit to list of depends if(absolutePath != this->absolutePath) { dependencies.push_back(FileInfo::create(absolutePath)); } //std::cout << "Processing: " << absolutePath << std::endl; std::ifstream file(absolutePath.c_str()); if(file.is_open() == false) { std::cout << "Warning: Failed to open: " << absolutePath << std::endl; throw std::exception(); } while(file.eof() == false) { std::string token; file >> token; if(token == "") continue; if(token.substr(0, 1) == "#") { if(token == "#") { std::string tmp; file >> tmp; token = token + tmp; } if(token.substr(0, 8) == "#include") { if(token == "#include") { std::string tmp; file >> tmp; token = token + tmp; } std::string dep = token.substr(8); if(dep.at(0) == '"') { dep = Util::trimLeft(dep, '"'); dep = Util::trimRight(dep, '"'); dep = Util::fixPath(getFolderPath(absolutePath) + DIR_CHAR + dep); try { //std::cout << "Processing: " << dep << std::endl; processInclude(dep); } catch(std::exception& e){} } else if(dep.at(0) == '<') { dep = Util::trimLeft(dep, '<'); dep = Util::trimRight(dep, '>'); for(int i = 0; i < additionalIncludeDirectories.size(); i++) { try { //std::cout << "Additional: " << additionalIncludeDirectories.at(i) << DIR_CHAR << dep << std::endl; processInclude(additionalIncludeDirectories.at(i) + DIR_CHAR + dep); } catch(std::exception& e){} } } } }
std::string Path::getShortPath(size_t idealLen, bool withFile) const { std::string fullPath; if (withFile) fullPath = getFullPath(); else fullPath = getFolderPath(); size_t len = fullPath.size(); if (idealLen > (uint32)len) return fullPath; std::vector<std::string> list = m_vPath; if (withFile && m_File.getFile() != "") list.push_back(m_File.getFile()); if (list.size() <= 1) return fullPath; size_t start = 0; size_t stop = list.size()-1; size_t count = 0; while (count < idealLen) { if (start == stop) break; size_t startLen = list[start].size(); size_t endLen = list[stop].size(); if (count + startLen < idealLen) { start++; count += startLen; } if (start == stop) break; if (count + endLen < idealLen) { stop--; count += endLen; } else { //failed to add start and end strings, lets stop break; } } Path out; bool first = true; for (size_t x=0; x<list.size(); x++) { if (x<start || x>stop) { out += list[x]; } else if (first) { first = false; out += "..."; } } return out.getFullPath(); }