@ -104,6 +104,20 @@ void showFileInfos(char *fileName)
write ( 1 , " \n " , 2 ) ;
}
int my_strcmp ( char * s1 , char * s2 )
{
int i ;
i = 0 ;
while ( s1 [ i ] )
{
if ( s1 [ i ] ! = s2 [ i ] )
return ( s1 [ i ] - s2 [ i ] ) ;
i + + ;
}
return ( s1 [ i ] - s2 [ i ] ) ;
}
void listDirContent ( char * leDossier )
{
DIR * dir ;
@ -119,15 +133,23 @@ void listDirContent(char *leDossier)
write ( 1 , " t'es bourré, on veut le nom d'un dossier et pas autre chose \n " , 61 ) ;
exit ( 1 ) ;
}
write ( 1 , " Probleme ouverture dossier \n " , 28 ) ;
write ( 1 , " Probleme ouverture dossier, droit d'acces ? \n " , 45 ) ;
return ;
}
path_length = my_strlen ( leDossier ) + NAME_MAX + 2 ;
fileAbsolPath = ( char * ) malloc ( path_length ) ;
while ( ( lesEntrees = readdir ( dir ) ) )
{
if ( /*lesEntrees->d_type == DT_REG || lesEntrees->d_type == DT_DIR*/ 1 )
if ( lesEntrees - > d_type = = DT_DIR & & my_strcmp ( lesEntrees - > d_name , " . " ) & & my_strcmp ( lesEntrees - > d_name , " .. " ) )
{
fileAbsolPath = my_strcat ( ( char * ) leDossier , lesEntrees - > d_name , path_length ) ;
showFileInfos ( fileAbsolPath ) ;
listDirContent ( fileAbsolPath ) ;
}
else
{
fileAbsolPath = my_strcat ( ( char * ) leDossier , lesEntrees - > d_name , path_length ) ; //La consigne indique les fichiers, mais l'exemple montre aussi des dossiers...
fileAbsolPath = my_strcat ( ( char * ) leDossier , lesEntrees - > d_name , path_length ) ;
showFileInfos ( fileAbsolPath ) ;
}
}