Changeset 20c4707de5a87ba0ed3c66b5f52bff9453c6abe7
- Timestamp:
- 18/02/06 20:03:44
(3 years ago)
- Author:
- Antoine Cellerier <dionoea@videolan.org>
- git-committer:
- Antoine Cellerier <dionoea@videolan.org> 1140289424 +0000
- git-parent:
[9cbb86d3234e6fa489d9cce18170c59b1b13ab4c]
- git-author:
- Antoine Cellerier <dionoea@videolan.org> 1140289424 +0000
- Message:
do everything with the stream functions (no more fopen)
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r8ca8d34 |
r20c4707 |
|
| 206 | 206 | block_t *p_block; |
|---|
| 207 | 207 | picture_t *p_pic; |
|---|
| 208 | | FILE *file; |
|---|
| 209 | 208 | stream_t *p_stream = NULL; |
|---|
| 210 | 209 | int i_size; |
|---|
| 211 | 210 | |
|---|
| 212 | | file = utf8_fopen( psz_url, "rb" ); |
|---|
| 213 | | if( file ) |
|---|
| 214 | | { |
|---|
| 215 | | fseek( file, 0, SEEK_END ); |
|---|
| 216 | | i_size = ftell( file ); |
|---|
| 217 | | fseek( file, 0, SEEK_SET ); |
|---|
| 218 | | } |
|---|
| 219 | | else |
|---|
| 220 | | { |
|---|
| 221 | | /*msg_Dbg( p_image->p_parent, "could not open file %s for reading", |
|---|
| 222 | | psz_url );*/ |
|---|
| 223 | | /* if file couldn't be opened, try to open the url with the stream |
|---|
| 224 | | * functions. Any url can be thus be opened. */ |
|---|
| 225 | | p_stream = stream_UrlNew( p_image->p_parent, psz_url ); |
|---|
| 226 | | if( !p_stream ) |
|---|
| 227 | | { |
|---|
| 228 | | msg_Dbg( p_image->p_parent, "could not open %s for reading", |
|---|
| 229 | | psz_url ); |
|---|
| 230 | | return NULL; |
|---|
| 231 | | } |
|---|
| 232 | | else |
|---|
| 233 | | { |
|---|
| 234 | | i_size = stream_Size( p_stream ); |
|---|
| 235 | | } |
|---|
| 236 | | } |
|---|
| | 211 | p_stream = stream_UrlNew( p_image->p_parent, psz_url ); |
|---|
| | 212 | if( !p_stream ) |
|---|
| | 213 | { |
|---|
| | 214 | msg_Dbg( p_image->p_parent, "could not open %s for reading", |
|---|
| | 215 | psz_url ); |
|---|
| | 216 | return NULL; |
|---|
| | 217 | } |
|---|
| | 218 | |
|---|
| | 219 | i_size = stream_Size( p_stream ); |
|---|
| 237 | 220 | |
|---|
| 238 | 221 | p_block = block_New( p_image->p_parent, i_size ); |
|---|
| 239 | 222 | |
|---|
| 240 | | if( file ) |
|---|
| 241 | | { |
|---|
| 242 | | fread( p_block->p_buffer, sizeof(char), i_size, file ); |
|---|
| 243 | | fclose( file ); |
|---|
| 244 | | } |
|---|
| 245 | | else |
|---|
| 246 | | { |
|---|
| 247 | | stream_Read( p_stream, p_block->p_buffer, i_size ); |
|---|
| 248 | | stream_Delete( p_stream ); |
|---|
| 249 | | } |
|---|
| | 223 | stream_Read( p_stream, p_block->p_buffer, i_size ); |
|---|
| | 224 | stream_Delete( p_stream ); |
|---|
| 250 | 225 | |
|---|
| 251 | 226 | if( !p_fmt_in->i_chroma ) |
|---|