Exemplo n.º 1
0
QStringList Mailbox::getUidDirPaths(QString path)
{
    QStringList uidPaths;
    QStringList shortIds = listDirectories(path);
    for (int i = 0; i < shortIds.count(); i++) {
        const QString &shortId = shortIds.at(i);
        if (shortId.size() != 2)
            continue;
        QString shortPath = path;
        if (shortPath != "")
            shortPath += "/";
        shortPath += shortId;
        QStringList restIds = listDirectories(shortPath);
        for (int a = 0; a < restIds.count(); a++)
            uidPaths.append(shortPath + "/" + restIds.at(a));

    }
    return uidPaths;
}
Exemplo n.º 2
0
	bool VFS::isDirectory(const std::string& path) const {
		std::vector<std::string> tokens;
		// Add a slash in case there isn't one in the string
		const std::string newpath = path + "/";
		boost::algorithm::split(tokens, newpath, boost::algorithm::is_any_of("/"));

		std::string currentpath = "/";
		std::vector<std::string>::const_iterator token=tokens.begin();
		while (token != tokens.end()) {
			if (*token != "") {
				if (*token != "." && *token != ".." && listDirectories(currentpath, *token).size() == 0) {
					return false;
				} else {
					currentpath += *token + "/";
				}
			}
			++token;
		}

		return true;
	}
Exemplo n.º 3
0
	std::set<std::string> VFS::listDirectories(const std::string& path, const std::string& filterregex) const {
		std::set<std::string> list = listDirectories(path);
		return filterList(list, filterregex);
	}
Exemplo n.º 4
0
bool KURLCompletion::fileCompletion(const MyURL &url, QString *match)
{
    if(url.protocol() != "file")
        return false;

    QString dir = url.dir();

    if(url.url()[0] == '.')
    {
        if(url.url().length() == 1)
        {
            *match = (completionMode() == KGlobalSettings::CompletionMan) ? "." : "..";
            return true;
        }
        if(url.url().length() == 2 && url.url()[1] == '.')
        {
            *match = "..";
            return true;
        }
    }

    // kdDebug() << "fileCompletion " << url.url() << " dir=" << dir << endl;

    dir = unescape(dir); // remove escapes

    // Find directories to search for completions, either
    //
    // 1. complete path given in url
    // 2. current directory (d->cwd)
    // 3. no directory at all

    QStringList dirList;

    if(!QDir::isRelativePath(dir))
    {
        // complete path in url
        dirList.append(dir);
    }
    else if(!d->cwd.isEmpty())
    {
        // current directory
        dirList.append(d->cwd + '/' + dir);
    }

    // No hidden files unless the user types "."
    bool no_hidden_files = (url.file().at(0) != '.');

    // List files if needed
    //
    if(!isListedURL(CTFile, dir, "", no_hidden_files))
    {
        stop();
        clear();

        setListedURL(CTFile, dir, "", no_hidden_files);

        // Append '/' to directories in Popup mode?
        bool append_slash = (d->popup_append_slash
                             && (completionMode() == KGlobalSettings::CompletionPopup || completionMode() == KGlobalSettings::CompletionPopupAuto));

        bool only_dir = (d->mode == DirCompletion);

        *match = listDirectories(dirList, "", false, only_dir, no_hidden_files, append_slash);
    }
    else if(!isRunning())
    {
        *match = finished();
    }
    else
    {
        *match = QString::null;
    }

    return true;
}
Exemplo n.º 5
0
bool KURLCompletion::exeCompletion(const MyURL &url, QString *match)
{
    if(url.protocol() != "file")
        return false;

    QString dir = url.dir();

    dir = unescape(dir); // remove escapes

    // Find directories to search for completions, either
    //
    // 1. complete path given in url
    // 2. current directory (d->cwd)
    // 3. $PATH
    // 4. no directory at all

    QStringList dirList;

    if(!QDir::isRelativePath(dir))
    {
        // complete path in url
        dirList.append(dir);
    }
    else if(!dir.isEmpty() && !d->cwd.isEmpty())
    {
        // current directory
        dirList.append(d->cwd + '/' + dir);
    }
    else if(!url.file().isEmpty())
    {
        // $PATH
        dirList = QStringList::split(KPATH_SEPARATOR, QString::fromLocal8Bit(::getenv("PATH")));

        QStringList::Iterator it = dirList.begin();

        for(; it != dirList.end(); it++)
            (*it).append('/');
    }

    // No hidden files unless the user types "."
    bool no_hidden_files = url.file().at(0) != '.';

    // List files if needed
    //
    if(!isListedURL(CTExe, dir, url.file(), no_hidden_files))
    {
        stop();
        clear();

        setListedURL(CTExe, dir, url.file(), no_hidden_files);

        *match = listDirectories(dirList, url.file(), true, false, no_hidden_files);
    }
    else if(!isRunning())
    {
        *match = finished();
    }
    else
    {
        if(d->dirListThread)
            setListedURL(CTExe, dir, url.file(), no_hidden_files);
        *match = QString::null;
    }

    return true;
}