Ejemplo n.º 1
0
bool
SkFontManager::openPreDataRead( SkStream ** preData )
{
    SkStream * stream = openReadStream( SYSTEM_DL_PREDATA_FILE );

    if( !stream )
    {
        if( permission_denied() )
            goto SKIP_ERROR0;

        if( !no_such_file() )
            goto ERROR0;

        goto SKIP_ERROR0;
    }

    *preData = stream;
    return true;

SKIP_ERROR0:
    return false;

ERROR0:
    if( stream )
        SkDELETE( stream );
    return false;
}
Ejemplo n.º 2
0
static int		move_to_dir(t_env *env, char *path)
{
	char	*oldpwd;
	char	*pwd;
	char	buffer[256];

	pwd = getcwd(buffer, 256);
	if (!pwd)
	{
		permission_denied("cd", path);
		return (1);
	}
	oldpwd = ft_strdup(pwd);
	if (chdir(path) == 0)
	{
		pwd = getcwd(buffer, 256);
		move_old_and_pwd(env, oldpwd, pwd);
		ft_memdel((void**)&oldpwd);
		return (0);
	}
	else
	{
		no_such_file(path);
		ft_memdel((void**)&oldpwd);
		return (-1);
	}
}
Ejemplo n.º 3
0
LoadState
SkFontManager::loadPreData( uint32_t * newFontIndex, bool boot )
{
    LoadState state = load_true;
    preDataHeader header = { 0, 0, 0 };
    uint32_t curFontIndex = ( boot == true ? readFontConfig() : getCurrentFontIndex() );
    uint32_t curNewFontIndex = curFontIndex;
    uint32_t numEmbeddedFonts = mEmbeddedFonts.numFonts();
    bool statePass = ( curFontIndex < numEmbeddedFonts ? true : false );
    bool system = ( newFontIndex != NULL ? true : false );
    SkStream * stream = NULL;

    if( openPreDataRead( &stream ) == false )
    {
        if( no_such_file() || permission_denied() )
            goto SKIP_ERROR0;

        HyLogef( "openPreDataRead(%s (%d))", strerror( errno ), errno );
        goto ERROR0;
    }

    stream->read( &header, SYSTEM_DL_PREDATA_HEADER_LEN );

    if( header.tag != __key() )
    {
        HyLogef( "Wrong tag" );
        goto ERROR0;
    }

LOAD_START:
    if( getUpdateVersion() == 0 ) // Boot Load & reload.
    {
        setUpdateVersion( header.updateVersion );

        if( header.count == 0 )
            goto SUCCEED0;

        for( uint32_t n = 0 ; n < header.count ; n++ )
        {
            SkFontData * font = SkNEW( SkFontData );

            if( font )
            {
                font->readPreData( stream );

                if( font->checkCertify( system ) == true )
                {
                    font->loadFont();
                    mDownloadFonts.addFonts( font );
                }
                else
                {
                    if( ( system == true ) && ( statePass == false ) )
                    {
                        if( state != load_restart )
                        {
                            if( ( numEmbeddedFonts + n ) == curFontIndex )
                            {
                                state = load_restart;
                            }
                            else
                            {
                                state = load_change;
                                if( ( numEmbeddedFonts + n ) < curFontIndex )
                                    curNewFontIndex--;
                            }
                        }
                    }
                    else
                    {
                        state = load_change;
                    }

                    font->deleteFiles();
                    SkDELETE( font );
                    font = NULL;
                }
            }
            else
            {
                HyLogef( "SkNEW( SkFontData )" );
                continue;
            }
        }
    }
    else // Fonts change
    {
        if( getUpdateVersion() == header.updateVersion )
        {
            goto SUCCEED0;
        }
        else
        {
            mDownloadFonts.resetFonts();
            setUpdateVersion( 0 );
            goto LOAD_START;
        }
    }

SUCCEED0:
    if( ( system == true ) && ( statePass == false ) )
    {
        switch( state )
        {
        case load_change:
            *newFontIndex = curNewFontIndex;
            break;
        case load_restart:
            *newFontIndex = SYSTEM_DEFAULT_FAMILY_INDEX;
            break;
        default:
            *newFontIndex = curFontIndex;
            break;
        }
    }
    else if( ( system == true ) && ( statePass == true ) )
    {
        *newFontIndex = curFontIndex;
    }

    if( stream )
        SkDELETE( stream );
    return state;

SKIP_ERROR0:
    return load_false;

ERROR0:
    if( stream )
        SkDELETE( stream );
    return load_false;
}