Exemple #1
0
string g_FindDataFile(const CTempString& name, CDirEntry::EType type)
{
#ifdef NCBI_OS_MSWIN
    static const char* kDelim = ";";
#else
    static const char* kDelim = ":";
#endif

    if ( !s_IgnoredDataFiles->empty()
        &&  CDirEntry::MatchesMask(name, *s_IgnoredDataFiles) ) {
        return kEmptyStr;
    }

    list<string> dirs;

    if (CDirEntry::IsAbsolutePath(name)) {
        dirs.push_back(kEmptyStr);
    } else {
        TNCBIDataPath path;
        TNCBIDataDir dir;

        if ( !path.Get().empty() ) {
            NStr::Split(path.Get(), kDelim, dirs);
        }
        if ( !dir.Get().empty() ) {
            dirs.push_back(dir.Get());
        }
    }

    CDirEntry candidate;
    EFollowLinks fl = (type == CDirEntry::eLink) ? eIgnoreLinks : eFollowLinks;
    ITERATE (list<string>, dir, dirs) {
        candidate.Reset(CDirEntry::MakePath(*dir, name));
        if (candidate.Exists() &&  candidate.GetType(fl) == type) {
            return candidate.GetPath();
        }
    }