Пример #1
0
/**
 * Takes a filename and tries to find it in the game's Data folders,
 * accounting for the system's case-sensitivity and path style.
 * @param filename Original filename.
 * @return Correct filename or "" if it doesn't exist.
 */
std::string getDataFile(const std::string &filename)
{
	// Correct folder separator
	std::string name = filename;
#ifdef _WIN32
	std::replace(name.begin(), name.end(), '/', PATH_SEPARATOR);
#endif

	// Check current data path
	std::string path = caseInsensitive(Options::getDataFolder(), name);
	if (path != "")
	{
		return path;
	}

	// Check every other path
	for (std::vector<std::string>::iterator i = Options::getDataList()->begin(); i != Options::getDataList()->end(); ++i)
	{
		std::string path = caseInsensitive(*i, name);
		if (path != "")
		{
			Options::setDataFolder(*i);
			return path;
		}
	}

	// Give up
	return filename;
}
Пример #2
0
//-------------------------------------------------------------------------------------------------------
ComponentLibrary::ComponentLibrary( const std::string &componentN, const std::string &categoryN, ClassEntry::SPtr e, const std::vector< std::string > &exampleFiles):  name(componentN), categoryName(categoryN),entry(e)
{

    description  = std::string("<H2>")  + entry->className + std::string(": ");

    std::vector< std::string > possiblePaths;

    std::vector<std::string> categories;
    const objectmodel::BaseClass* entryClass = entry->creatorMap.begin()->second->getClass();
    CategoryLibrary::getCategories(entryClass, categories);
    for (std::vector< std::string >::iterator it=categories.begin(); it!=categories.end() ; ++it)
    {
        if (it != categories.begin()) description += std::string(", ");
        description += (*it);
    }

    //Find a scene
    std::string nameComponentCaseInsensitive = caseInsensitive(entry->className);

    for (unsigned int i=0; i<exampleFiles.size(); ++i)
    {
        std::string exampleCaseInsensitive = caseInsensitive(exampleFiles[i]);
//             if (exampleFiles[i].findRev(entry->className.c_str()) >= 0 )
        if (exampleCaseInsensitive.find(nameComponentCaseInsensitive) != std::string::npos)
            possiblePaths.push_back(exampleFiles[i]);
    }

    std::string nameSpace = sofa::core::objectmodel::BaseClass::decodeNamespaceName(entry->creatorMap.begin()->second->type());


    description += std::string("</H2>");

    description += std::string("<ul>");

    description += std::string("<li><b>Description: </b>") + entry->description + std::string("</li>");


    if (!nameSpace.empty())
        description += std::string("<li><b>NameSpace: </b>")+nameSpace +std::string("</li>");
    if (!entry->authors.empty())
        description += std::string("<li><b>Authors: </b>")+entry->authors +std::string("</li>");
    if (!entry->license.empty())
        description += std::string("<li><b>License: </b>") + entry->license + std::string("</li>");

    if (possiblePaths.size() != 0)
    {
        description += std::string("<li><b>Example: </b><ul>");
        for (unsigned int i=0; i<possiblePaths.size(); ++i)
        {
            description += std::string("<li><a href=\"")+possiblePaths[i]+std::string("\">") + possiblePaths[i] + std::string("</a></li>");
        }
        description += std::string("</ul>");
    }

    description += std::string("</ul>");
}