Exemple #1
0
String XmlDocument::getFileContents (const String& filename) const
{
    if (inputSource != nullptr)
    {
        const ScopedPointer<InputStream> in (inputSource->createInputStreamFor (filename.trim().unquoted()));

        if (in != nullptr)
            return in->readEntireStreamAsString();
    }

    return {};
}
Exemple #2
0
bool ModuleList::loadFromWebsite()
{
    modules.clear();

    URL baseURL ("http://www.juce.com/juce/modules");
    URL url (baseURL.getChildURL ("modulelist.php"));

    const ScopedPointer<InputStream> in (url.createInputStream (false, nullptr, nullptr, String::empty, 4000));

    if (in == nullptr)
        return false;

    var infoList (JSON::parse (in->readEntireStreamAsString()));

    if (! infoList.isArray())
        return false;

    const Array<var>* moduleList = infoList.getArray();

    for (int i = 0; i < moduleList->size(); ++i)
    {
        const var& m = moduleList->getReference(i);
        const String file (m [Ids::file].toString());

        if (file.isNotEmpty())
        {
            ModuleDescription lm (m [Ids::info]);

            if (lm.isValid())
            {
                lm.url = baseURL.getChildURL (file);
                modules.add (new ModuleDescription (lm));
            }
        }
    }

    sort();
    return true;
}