コード例 #1
0
LanguagePack * LanguagePack::FromFile(uint16 id, const utf8 * path)
{
    assert(path != nullptr);

    // Load file directly into memory
    utf8 * fileData = nullptr;
    try
    {
        FileStream fs = FileStream(path, FILE_MODE_OPEN);
        
        size_t fileLength = (size_t)fs.GetLength();
        if (fileLength > MAX_LANGUAGE_SIZE)
        {
            throw IOException("Language file too large.");
        }

        fileData = Memory::Allocate<utf8>(fileLength + 1);
        fs.Read(fileData, fileLength);
        fileData[fileLength] = '\0';
    }
    catch (Exception ex)
    {
        Memory::Free(fileData);
        log_error("Unable to open %s: %s", path, ex.GetMessage());
        return nullptr;
    }

    // Parse the memory as text
    LanguagePack * result = FromText(id, fileData);

    Memory::Free(fileData);
    return result;
}
コード例 #2
0
ファイル: PointSizeRect.cpp プロジェクト: richardxday/rdlib
AColour::AColour(const char *pText)
{
	FromText(pText);
}