示例#1
0
文件: config.c 项目: actility/ong
char	*FindConfigCluster(unsigned int cluster,char *addr)
{
	char	*awd;
	char	dir[1024];
	char	*ret	= NULL;


	awd	= getenv(GetEnvVarName());
	if	(awd)
	{
		sprintf	(dir,"%s/sensorconfig",awd);
		ret	= FindInDir(dir,cluster);
		if	(ret)
			return	ret;
	}
#if	0	// on cherche plus la config des clusters dans la livraison
	awd	= getenv("ROOTACT");
	if	(awd)
	{
		sprintf	(dir,"%s/%s/sensorconfig",awd,GetAdaptorName());
		ret	= FindInDir(dir,cluster);
		if	(ret)
			return	ret;
	}
#endif


	return	ret;
}
 bool findIncludeFile (util::String const & inclname, util::String const & name, bool sys, util::String & fullname)
 {
   // if absolute then no need to search path
   bool result = false;
   if (isAbsolute (name))
   {
     if (exists (name))
     {
       result = true;
       fullname = name;
     }
   }
   // otherwise search in curent dir if not sys 
   else if (! sys && findInDir (getPath (inclname), name, fullname))
   {
     result = true;
   }
   else
   {
     // search in path list
     util::StringVector const & path_set = conf::getOptionValue (conf::opt_incl_path_set);
     result = std::find_if (path_set.begin (), path_set.end (), FindInDir (name, fullname)) != path_set.end ();
   }
   return result;
 }
示例#3
0
int SourceDigger::FindInDir(const wxString& dirname, wxArrayString& files)
{
    wxDir dir(dirname);
    if (!dir.IsOpened()) 
        return 0;
    bool cont;
    wxString filename;
    int found = 0;
    
    cont = dir.GetFirst(&filename, wxEmptyString, wxDIR_FILES);
    while (cont)
    {
        files.Add(dirname + _T("/") + filename);
        found++;
        cont = dir.GetNext(&filename);
    }    

    cont = dir.GetFirst(&filename, wxEmptyString, wxDIR_DIRS);
    while (cont)
    {
        found += FindInDir(dirname + _T("/") + filename, files);
        cont = dir.GetNext(&filename);
    }

    return found;
}
示例#4
0
wxArrayString *SourceDigger::FindFiles(const wxArrayString& paths, 
                                       ParsersDB& pdb)
{
    if (pdb.GetCount() == 0)
      return NULL;
    wxArrayString *p_files = new wxArrayString[pdb.GetCount()];
    wxArrayString files;
    size_t i;
    
    for (i = 0; i < paths.GetCount(); i++)
    {
        if ( !FindInDir(paths[i], files) )
            wxLogWarning(_("No files found in: ") + paths[i]);
    }

    size_t filescnt = 0;
    for (i = 0; i < pdb.GetCount(); i++)
    {
        p_files[i] = pdb[i].SelectParsable(files);
        filescnt += p_files[i].GetCount();
    }
    m_progressInfo->SetGaugeMax(filescnt);
    
    if (filescnt == 0)
        wxLogError(_("Poedit did not find any files in scanned directories."));

    return p_files;
}
示例#5
0
wxArrayString *SourceDigger::FindFiles(const wxArrayString& paths,
                                       const PathsToMatch& excludePaths,
                                       ExtractorsDB& db)
{
    if (db.Data.empty())
      return NULL;

    wxArrayString *p_files = new wxArrayString[db.Data.size()];
    wxArrayString files;
    size_t i;
    
    for (i = 0; i < paths.GetCount(); i++)
    {
        if (wxFileName::FileExists(paths[i]))
        {
            if (excludePaths.MatchesFile(paths[i]))
            {
                wxLogTrace("poedit", "no files found in '%s'", paths[i]);
                continue;
            }
            files.Add(paths[i]);
        }
        else if ( !FindInDir(paths[i], excludePaths, files) )
        {
            wxLogTrace("poedit", "no files found in '%s'", paths[i]);
        }
    }

    // Sort the filenames in some well-defined order. This is because directory
    // traversal has, generally speaking, undefined order, and the order differs
    // between filesystems. Finally, the order is reflected in the created PO
    // files and it is much better for diffs if it remains consistent.
    files.Sort();

    size_t filescnt = 0;
    for (i = 0; i < db.Data.size(); i++)
    {
        if (!db.Data[i].Enabled)
            continue;
        p_files[i] = db.Data[i].SelectParsable(files);
        filescnt += p_files[i].GetCount();
    }
    m_progressInfo->SetGaugeMax((int)filescnt);
    
    if (filescnt == 0)
        return nullptr;

    return p_files;
}
示例#6
0
bool PathJoin (char *target, const char *base, ...)
{
	if (base == NULL) {
		target[0] = '\0';
		return false;
	}
	if (base != target) {
		strcpy(target, base);
	}

	va_list ap;
	va_start(ap, base);

	while (char *source = va_arg(ap, char*)) {
		char *slash;
		do {
			char filename[_MAX_PATH] = { '\0' };
			slash = strchr(source, PathDelimiter);
			if (slash == source) {
				++source;
				continue;
			} else if (slash) {
				strncat(filename, source, slash-source);
			} else {
				strcpy(filename, source);
			}
			if (!FindInDir(target, filename)) {
				PathAppend(target, source);
				goto finish;
			}
			PathAppend(target, filename);
			source = slash + 1;
		} while (slash);
	}

	va_end( ap );
	return true;

finish:
	while (char *source = va_arg(ap, char*)) {
		PathAppend(target, source);
	}
	va_end( ap );
	return false;
}
示例#7
0
文件: digger.cpp 项目: mapme/poedit
int SourceDigger::FindInDir(const wxString& dirname,
                            const wxArrayString& excludePaths,
                            wxArrayString& files)
{
    if (dirname.empty())
        return 0;
    wxDir dir(dirname);
    if (!dir.IsOpened()) 
        return 0;
    bool cont;
    wxString filename;
    int found = 0;
    
    cont = dir.GetFirst(&filename, wxEmptyString, wxDIR_FILES);
    while (cont)
    {
        const wxString f = (dirname == ".") ? filename : dirname + "/" + filename;
        cont = dir.GetNext(&filename);

        if (FilenameMatchesPathsList(f, excludePaths))
            continue;

        files.Add(f);
        found++;
    }

    cont = dir.GetFirst(&filename, wxEmptyString, wxDIR_DIRS);
    while (cont)
    {
        const wxString f = (dirname == ".") ? filename : dirname + "/" + filename;
        cont = dir.GetNext(&filename);

        if (FilenameMatchesPathsList(f, excludePaths))
            continue;

        found += FindInDir(f, excludePaths, files);
    }

    return found;
}
示例#8
0
文件: digger.cpp 项目: mapme/poedit
wxArrayString *SourceDigger::FindFiles(const wxArrayString& paths,
                                       const wxArrayString& excludePaths,
                                       ExtractorsDB& db)
{
    if (db.Data.empty())
      return NULL;

    wxArrayString *p_files = new wxArrayString[db.Data.size()];
    wxArrayString files;
    size_t i;
    
    for (i = 0; i < paths.GetCount(); i++)
    {
        if ( !FindInDir(paths[i], excludePaths, files) )
        {
            wxLogWarning(_("No files found in: ") + paths[i]);
        }
    }

    // Sort the filenames in some well-defined order. This is because directory
    // traversal has, generally speaking, undefined order, and the order differs
    // between filesystems. Finally, the order is reflected in the created PO
    // files and it is much better for diffs if it remains consistent.
    files.Sort();

    size_t filescnt = 0;
    for (i = 0; i < db.Data.size(); i++)
    {
        p_files[i] = db.Data[i].SelectParsable(files);
        filescnt += p_files[i].GetCount();
    }
    m_progressInfo->SetGaugeMax((int)filescnt);
    
    if (filescnt == 0)
    {
        wxLogError(_("Poedit did not find any files in scanned directories."));
    }

    return p_files;
}