Logo Search packages:      
Sourcecode: inkscape version File versions

bool buildtool::MakeBase::listFiles ( const String &  baseName,
const String &  dirname,
std::vector< String > &  result 
) [protected, inherited]

Find all files in the named directory

Definition at line 3732 of file buildtool.cpp.

References buildtool::MakeBase::error(), buildtool::MakeBase::getNativePath(), buildtool::MakeBase::isDirectory(), and buildtool::MakeBase::isRegularFile().

Referenced by buildtool::MakeBase::listFiles().

{
    String fullDir = baseDir;
    if (dirName.size()>0)
        {
        fullDir.append("/");
        fullDir.append(dirName);
        }
    String dirNative = getNativePath(fullDir);

    std::vector<String> subdirs;
    DIR *dir = opendir(dirNative.c_str());
    if (!dir)
        {
        error("Could not open directory %s : %s",
              dirNative.c_str(), strerror(errno));
        return false;
        }
    while (true)
        {
        struct dirent *de = readdir(dir);
        if (!de)
            break;

        //Get the directory member name
        String s = de->d_name;
        if (s.size() == 0 || s[0] == '.')
            continue;
        String childName;
        if (dirName.size()>0)
            {
            childName.append(dirName);
            childName.append("/");
            }
        childName.append(s);
        String fullChild = baseDir;
        fullChild.append("/");
        fullChild.append(childName);
        
        if (isDirectory(fullChild))
            {
            //trace("directory: %s", childName.c_str());
            if (!listFiles(baseDir, childName, res))
                return false;
            continue;
            }
        else if (!isRegularFile(fullChild))
            {
            error("unknown file:%s", childName.c_str());
            return false;
            }

       //all done!
        res.push_back(childName);

        }
    closedir(dir);

    return true;
}


Generated by  Doxygen 1.6.0   Back to index