Changeset 3e6aa513530fc81c4df84736ff983194e213a7dd
- 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
| rcf34550 |
r3e6aa51 |
|
| 216 | 216 | int vlm_Load( vlm_t *p_vlm, const char *psz_file ) |
|---|
| 217 | 217 | { |
|---|
| 218 | | FILE *file; |
|---|
| | 218 | stream_t *p_stream; |
|---|
| 219 | 219 | int64_t i_size; |
|---|
| 220 | 220 | char *psz_buffer; |
|---|
| … | … | |
| 222 | 222 | if( !p_vlm || !psz_file ) return 1; |
|---|
| 223 | 223 | |
|---|
| 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 ); |
|---|
| 230 | 230 | return 2; |
|---|
| 231 | 231 | } |
|---|
| 232 | 232 | |
|---|
| 233 | | i_size = ftell( file ); |
|---|
| 234 | | fseek( file, 0, SEEK_SET ); |
|---|
| | 233 | i_size = stream_Size( p_stream ); |
|---|
| | 234 | |
|---|
| 235 | 235 | psz_buffer = malloc( i_size + 1 ); |
|---|
| 236 | 236 | if( !psz_buffer ) |
|---|
| 237 | 237 | { |
|---|
| 238 | | fclose( file ); |
|---|
| | 238 | stream_Delete( p_stream ); |
|---|
| 239 | 239 | return 2; |
|---|
| 240 | 240 | } |
|---|
| 241 | | fread( psz_buffer, 1, i_size, file ); |
|---|
| | 241 | |
|---|
| | 242 | stream_Read( p_stream, psz_buffer, i_size ); |
|---|
| 242 | 243 | psz_buffer[ i_size ] = '\0'; |
|---|
| | 244 | |
|---|
| | 245 | stream_Delete( p_stream ); |
|---|
| | 246 | |
|---|
| 243 | 247 | if( Load( p_vlm, psz_buffer ) ) |
|---|
| 244 | 248 | { |
|---|
| 245 | | fclose( file ); |
|---|
| 246 | 249 | free( psz_buffer ); |
|---|
| 247 | 250 | return 3; |
|---|
| … | … | |
| 249 | 252 | |
|---|
| 250 | 253 | free( psz_buffer ); |
|---|
| 251 | | fclose( file ); |
|---|
| 252 | 254 | |
|---|
| 253 | 255 | return 0; |
|---|