Professional Documents
Culture Documents
Pauta Auxiliar 8
Pauta Auxiliar 8
Auxiliar 6
Profesor: Luis Mateu
Auxiliar: Alexandra Ibarra
1. Input / Output
1.1. Parte I
1 #i n c l u d e <s t d i o . h>
2 #i n c l u d e <d i r e n t . h> /∗ Manejo de d i r e c t o r i o s ∗/
3 #i n c l u d e <s y s / s t a t . h> /∗ Funcion s t a t y l s t a t ∗/
4 #i n c l u d e <s t r i n g . h>
5 #i n c l u d e <u n i s t d . h> /∗ Tipos y c o n s t a n t e s e s t a n d a r ∗/
6
7 void f i n d ( ) {
8 DIR ∗ c u r r e n t d i r ;
9 struct dirent ∗ this entry ;
10 struct stat status ;
11
12 i f ( ( c u r r e n t d i r=o p e n d i r ( ” . ” ) )==NULL)
13 r e t u r n ; /∗ e r r o r ∗/
14
15 f o r ( t h i s e n t r y = r e a d d i r ( c u r r e n t d i r ) ; t h i s e n t r y != NULL; t h i s e n t r y = r e a d d i r (
current dir ) ) {
16 i f ( strcmp ( t h i s e n t r y −>d name , ” . . ” ) == 0 | | strcmp ( t h i s e n t r y −>d name , ” . ” ) == 0 )
17 c o n t i n u e ; /∗ ignoramos l a c a r p e t a a c t u a l y su padre ∗/
18
19 i f ( l s t a t ( t h i s e n t r y −>d name , &s t a t u s ) != 0 )
20 c o n t i n u e ; /∗ e r r o r ∗/
21
22 if ( ! S ISDIR ( s t a t u s . st mode ) )
23 continue ;
24
25 p r i n t f ( ” %s \n” , t h i s e n t r y −>d name ) ;
26
27 /∗ cambiamos e l d i r e c t o r i o a l r e c i e n i m p r e s o ∗/
28 c h d i r ( t h i s e n t r y −>d name ) ;
29 find () ;
30 chdir (” . . ”) ;
31 }
32 closedir ( current dir ) ;
33 }
34
35 i n t main ( i n t argc , c h a r c o n s t ∗ argv [ ] ) {
36 find () ;
37 return 0;
38 }
1
2. Procesos
2.1. Parte I
2.2. Parte II