Changeset 3e6aa513530fc81c4df84736ff983194e213a7dd

Show
Ignore:
Timestamp:
02/28/06 13:45:37 (3 years ago)
Author:
Antoine Cellerier <dionoea@videolan.org>
git-committer:
Antoine Cellerier <dionoea@videolan.org> 1141130737 +0000
git-parent:

[7e7d587a44280a84914474364c6806f948af17cb]

git-author:
Antoine Cellerier <dionoea@videolan.org> 1141130737 +0000
Message:

Use VLC stream functions to load vlm configs. Refs #567

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/misc/vlm.c

    rcf34550 r3e6aa51  
    216216int vlm_Load( vlm_t *p_vlm, const char *psz_file ) 
    217217{ 
    218     FILE *file
     218    stream_t *p_stream
    219219    int64_t i_size; 
    220220    char *psz_buffer; 
     
    222222    if( !p_vlm || !psz_file ) return 1; 
    223223 
    224     file = utf8_fopen( psz_file, "r" ); 
    225     if( file == NULL ) return 1; 
    226  
    227     if( fseek( file, 0, SEEK_END) != 0 ) 
    228     { 
    229         fclose( file ); 
     224    p_stream = stream_UrlNew( p_vlm, psz_file ); 
     225    if( p_stream == NULL ) return 1; 
     226 
     227    if( stream_Seek( p_stream, 0 ) != 0 ) 
     228    { 
     229        stream_Delete( p_stream ); 
    230230        return 2; 
    231231    } 
    232232 
    233     i_size = ftell( file ); 
    234     fseek( file, 0, SEEK_SET ); 
     233    i_size = stream_Size( p_stream ); 
     234 
    235235    psz_buffer = malloc( i_size + 1 ); 
    236236    if( !psz_buffer ) 
    237237    { 
    238         fclose( file ); 
     238        stream_Delete( p_stream ); 
    239239        return 2; 
    240240    } 
    241     fread( psz_buffer, 1, i_size, file ); 
     241 
     242    stream_Read( p_stream, psz_buffer, i_size ); 
    242243    psz_buffer[ i_size ] = '\0'; 
     244 
     245    stream_Delete( p_stream ); 
     246 
    243247    if( Load( p_vlm, psz_buffer ) ) 
    244248    { 
    245         fclose( file ); 
    246249        free( psz_buffer ); 
    247250        return 3; 
     
    249252 
    250253    free( psz_buffer ); 
    251     fclose( file ); 
    252254 
    253255    return 0;