bool Env::loadPlugins(const parser::Ini::section_key_val &fileKeys) { for (parser::Ini::section_key_val::const_iterator itSect = fileKeys.begin(); itSect != fileKeys.end(); ++itSect) { if (isPluginSection(itSect->first, itSect->second)) { if (itSect->second.find("NAME") == itSect->second.end()) { std::cerr << "Ini Warning: Can't load " << itSect->first << std::endl << "Detail: There is no \"NAME\" key." << std::endl; continue; } if (itSect->second.find("USED") != itSect->second.end() && itSect->second.find("USED")->second == "yes") plugin.plugins.push_back(PluginDetail(itSect->second.find("NAME")->second, resolveFilePath(itSect->second.find("NAME")->second), true)); else plugin.plugins.push_back(PluginDetail(itSect->second.find("NAME")->second, resolveFilePath(itSect->second.find("NAME")->second))); } } return (true); }
bool QFileSystemEntry::isClean() const { resolveFilePath(); int dots = 0; bool dotok = true; // checking for ".." or "." starts to relative paths bool slashok = true; for (QString::const_iterator iter = m_filePath.constBegin(); iter != m_filePath.constEnd(); iter++) { if (*iter == QLatin1Char('/')) { if (dots == 1 || dots == 2) return false; // path contains "./" or "../" if (!slashok) return false; // path contains "//" dots = 0; dotok = true; slashok = false; } else if (dotok) { slashok = true; if (*iter == QLatin1Char('.')) { dots++; if (dots > 2) dotok = false; } else { //path element contains a character other than '.', it's clean dots = 0; dotok = false; } } } return (dots != 1 && dots != 2); // clean if path doesn't end in . or .. }
bool QFileSystemEntry::isDriveRoot() const { resolveFilePath(); return (m_filePath.length() == 3 && m_filePath.at(0).isLetter() && m_filePath.at(1) == QLatin1Char(':') && m_filePath.at(2) == QLatin1Char('/')); }
bool QFileSystemEntry::isAbsolute() const { resolveFilePath(); return (!m_filePath.isEmpty() && ((m_filePath.length() >= 3 && (m_filePath[0].isLetter() && m_filePath[1].unicode() == ':' && m_filePath[2].unicode() == '/')) || (m_filePath.length() >= 2 && (m_filePath.at(0) == QLatin1Char('/') && m_filePath.at(1) == QLatin1Char('/'))) )); }
void QFileSystemEntry::findLastSeparator() const { if (m_lastSeparator == -2) { resolveFilePath(); m_lastSeparator = -1; for (int i = m_filePath.size() - 1; i >= 0; --i) { if (m_filePath[i].unicode() == '/') { m_lastSeparator = i; break; } } } }
bool QFileSystemEntry::isRoot() const { resolveFilePath(); if (m_filePath == QLatin1String("/") #if defined(Q_OS_WIN) || isDriveRoot() || isUncRoot(m_filePath) #endif ) return true; return false; }
void QFileSystemEntry::findFileNameSeparators() const { if (m_firstDotInFileName == -2) { resolveFilePath(); int firstDotInFileName = -1; int lastDotInFileName = -1; int lastSeparator = m_lastSeparator; int stop; if (lastSeparator < 0) { lastSeparator = -1; stop = 0; } else { stop = lastSeparator; } int i = m_filePath.size() - 1; for (; i >= stop; --i) { if (m_filePath[i].unicode() == '.') { firstDotInFileName = lastDotInFileName = i; break; } else if (m_filePath[i].unicode() == '/') { lastSeparator = i; break; } } if (lastSeparator != i) { for (--i; i >= stop; --i) { if (m_filePath[i].unicode() == '.') firstDotInFileName = i; else if (m_filePath[i].unicode() == '/') { lastSeparator = i; break; } } } m_lastSeparator = lastSeparator; m_firstDotInFileName = firstDotInFileName == -1 ? -1 : firstDotInFileName - qMax(0, lastSeparator); if (lastDotInFileName == -1) m_lastDotInFileName = -1; else if (firstDotInFileName == lastDotInFileName) m_lastDotInFileName = 0; else m_lastDotInFileName = lastDotInFileName - firstDotInFileName; } }
bool QFileSystemEntry::isAbsolute() const { resolveFilePath(); return (!m_filePath.isEmpty() && (m_filePath[0].unicode() == '/')); }
bool QFileSystemEntry::isRelative() const { resolveFilePath(); return (m_filePath.isEmpty() || (!m_filePath.isEmpty() && (m_filePath[0].unicode() != '/') && (!(m_filePath.length() >= 2 && m_filePath[1].unicode() == ':')))); }
QString QFileSystemEntry::filePath() const { resolveFilePath(); return m_filePath; }