]> git.sesse.net Git - vlc/commitdiff
lecon de programmation a l'intention des debutants qui ont ecrit
authorJean-Philippe Grimaldi <jeanphi@videolan.org>
Tue, 24 Oct 2000 23:16:26 +0000 (23:16 +0000)
committerJean-Philippe Grimaldi <jeanphi@videolan.org>
Tue, 24 Oct 2000 23:16:26 +0000 (23:16 +0000)
input_file.c :
- les codes d'erreur sont fait pour etre utilises
- quand on ouvre un fichier on le referme
-- jeanphi

src/input/input_file.c

index b9f0f79522de4ae88c8af207702ee31de281144d..1e8994e3b23d6ea219fc6ab09c4ca80711ec5bd7 100644 (file)
@@ -738,7 +738,7 @@ ssize_t ps_read( options_t *p_options, ps_t * p_ps, void *ts )
             /* read some bytes */
             readbytes = safe_read( p_options, p_ps->ps_buffer + datasize, PS_BUFFER_SIZE - datasize);
 
-            if(readbytes == 0)
+            if(readbytes <= 0)
             {
                 input_file.b_die = 1;
                 return -1;
@@ -1021,12 +1021,18 @@ int input_FileOpen( input_thread_t *p_input )
 
     if( file_next( p_options ) < 0 )
     {
-        intf_ErrMsg( "input error: cannot open the file %s",
+        intf_ErrMsg( "input error: cannot open the file %s\n",
                      p_input->p_source );
+        return( 1 );
     }
 
     input_file.b_die = 0;
-    safe_read( p_options, &p_options->i_file_type, 1 );
+    if( safe_read( p_options, &p_options->i_file_type, 1 ) <= 0 )
+    {
+        intf_ErrMsg( "input error: cannot read file type\n");
+        close( p_options->in );
+        return( 1 );
+    }
     
     switch( p_options->i_file_type )
     {
@@ -1036,9 +1042,11 @@ int input_FileOpen( input_thread_t *p_input )
         break;
     case 0x47:
         intf_ErrMsg( "input error: ts files are not currently supported\n" );
+        close( p_options->in );
         return( 1 );
     default:
         intf_ErrMsg( "input error: cannot determine stream type\n" );
+        close( p_options->in );
         return( 1 );
     }