//---------------------------------------------------------------------
void CqDSORepository::SetDSOPath(const char* pathStr)
{
	if ( pathStr == NULL )
		return;

	// Scan through all the paths in the search path
	std::string pathString = pathStr;
	TqPathsTokenizer paths(pathString);
	for(TqPathsTokenizer::iterator path = paths.begin(), end = paths.end();
			path != end; ++path)
	{
		try
		{
			if(boost::filesystem::is_directory(*path))
			{
				// If the path points to a directory, we add each library in the
				// named directory to the list of DSO candidates.
				std::vector<std::string> files = Glob(
					((*path)/"*" SHARED_LIBRARY_SUFFIX).string<std::string>() );
				m_DSOPathList.insert(m_DSOPathList.end(), files.begin(), files.end());
			}
			else
			{
				// else add the file itself.
				m_DSOPathList.push_back(path->string<std::string>());
			}
		}
		catch(boost::filesystem::filesystem_error& /*e*/)
		{
			// ignore any errors.
		}
	}
}
Beispiel #2
0
int StripCmd(const vector<string>& args)
{
    // -- Check arguments:

    if (args.size() < 4)
    {
	cerr << args[0] << ": insufficient arguments" << endl;
	return 1;
    }

    // -- Create complete glob list:

    vector<string> fileNames;

    for (size_t i = 3; i < args.size(); i++)
	Glob(args[i], fileNames);

    for (size_t j = 0; j < fileNames.size(); j++)
    {
	int result = _Strip(args[0], args[1], args[2], fileNames[j]);

	if (result != 0)
	    return result;
    }

    return 0;
}
Beispiel #3
0
	Glob Interpreter::glob(const char* name) const {
		GV* const ret = gv_fetchpv(name, GV_ADD, SVt_PV);
		return Glob(raw_interp.get(), ret);
	}
Beispiel #4
0
static int printGlob(const char * path)
{
    rpmop op = memset(alloca(sizeof(*op)), 0, sizeof(*op));
    glob_t gl = { .gl_pathc = 0, .gl_pathv = NULL, .gl_offs = 0 };
    int rc;
    int xx;

fprintf(stderr, "===== %s\n", path);
    xx = rpmswEnter(op, 0);
    gl.gl_pathc = 0;
    gl.gl_pathv = NULL;
    gl.gl_offs = 0;
    rc = Glob(path, 0, my_Glob_error, &gl);
    if (rc != 0) {
fprintf(stderr, "*** Glob rc %d\n", rc);
    } else
    if (rpmIsVerbose()) {
	int i;
	for (i = 0; i < (int)gl.gl_pathc; i++)
	    fprintf(stderr, "%5d %s\n", i, gl.gl_pathv[i]);
    }
    Globfree(&gl);
    xx = rpmswExit(op, 0);

    if (_rpmsw_stats)
	rpmswPrint("glob:", op, NULL);
    return rc;
}

static struct poptOption optionsTable[] = {
 { "debug", 'd', POPT_ARG_VAL,	&__debug, -1,		NULL, NULL },

 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmioAllPoptTable, 0,
	N_("Common options for all rpmio executables:"),
	NULL },

  POPT_AUTOHELP
  POPT_TABLEEND
};

int
main(int argc, char *argv[])
{
    poptContext optCon = rpmioInit(argc, argv, optionsTable);
    ARGV_t av;
    int ac;
    const char * dn;
    int rc = 0;

    if (__debug) {
_av_debug = -1;
_dav_debug = -1;
_ftp_debug = -1;
_url_debug = -1;
_rpmio_debug = -1;
    }

    av = poptGetArgs(optCon);
    ac = argvCount(av);
    if (ac < 1) {
	poptPrintUsage(optCon, stderr, 0);
	goto exit;
    }

    while (rc == 0 && (dn = *av++) != NULL)
	rc = printGlob(dn);

exit:

    optCon = rpmioFini(optCon);

    return rc;
}
Beispiel #5
0
// uses a QIODevice to make unit tests possible
bool KMimeGlobsFileParser::parseGlobFile(QIODevice* file, Format format, AllGlobs& globs)
{
    if (!file->open(QIODevice::ReadOnly))
        return false;

    // If we're not going to get the "cs" flag because smi is too old, then we need to emulate it for *.C at least.
    const bool caseSensitiveHackNeeded = (KMimeType::sharedMimeInfoVersion() <= KDE_MAKE_VERSION(0, 60, 0));

    QTextStream stream(file);
    //stream.setCodec("UTF-8"); // should be all latin1
    QString lastMime, lastPattern;
    QString line;
    while (!stream.atEnd()) {
        line = stream.readLine();
        if (line.isEmpty() || line.startsWith(QLatin1Char('#')))
            continue;

        const QStringList fields = line.split(QLatin1Char(':'), QString::KeepEmptyParts);
        if (fields.count() < 2) // syntax error
            continue;

        //kDebug() << "line=" << line;

        QString mimeTypeName, pattern;
        QStringList flagList;
        int weight = 50;
        if (format == Globs2WithWeight) {
            if (fields.count() < 3) // syntax error
                continue;
            weight = fields[0].toInt();
            mimeTypeName = fields[1];
            pattern = fields[2];
            const QString flagsStr = fields.value(3); // could be empty
            flagList = flagsStr.split(QLatin1Char(','), QString::SkipEmptyParts);
        } else {
            mimeTypeName = fields[0];
            pattern = fields[1];
        }
        Q_ASSERT(!pattern.isEmpty());
        Q_ASSERT(!pattern.contains(QLatin1Char(':')));

        //kDebug() << " got:" << mimeTypeName << pattern;

        if (lastMime == mimeTypeName && lastPattern == pattern) {
            // Ignore duplicates, especially important for those with no flags after a line with flags:
            // 50:text/x-csrc:*.c:cs
            // 50:text/x-csrc:*.c
            continue;
        }

        bool caseSensitive = flagList.contains(QLatin1String("cs"));

        if (caseSensitiveHackNeeded && (pattern == QLatin1String("*.C") || pattern == QLatin1String("*.c") || pattern == QLatin1String("core")))
            caseSensitive = true;

        if (pattern == QLatin1String("__NOGLOBS__")) {
            //kDebug() << "removing" << mimeTypeName;
            globs.removeMime(mimeTypeName);
            lastMime.clear();
        } else {
            int flags = 0;
            if (caseSensitive)
                flags = KMimeTypeRepository::CaseSensitive;

            //if (mimeTypeName == "text/plain")
            //    kDebug() << "Adding pattern" << pattern << "to mimetype" << mimeTypeName << "from globs file, with weight" << weight;
            //if (pattern.toLower() == "*.c")
            //    kDebug() << " Adding pattern" << pattern << "to mimetype" << mimeTypeName << "from globs file, with weight" << weight << "flags" << flags;
            globs.addGlob(Glob(mimeTypeName, weight, pattern, flags));
            lastMime = mimeTypeName;
            lastPattern = pattern;
        }
    }
    return true;
}
Beispiel #6
0
std::vector<std::string> cliGlob( const std::string& pattern )
{
	return Glob(pattern);
}