Linux - COMO SABER SI ES UN DIRECTORIO O NO???

 
Vista:

COMO SABER SI ES UN DIRECTORIO O NO???

Publicado por joaquin (2 intervenciones) el 18/05/2006 21:18:15
HOLA MI DUDA ES LA SIGUIENTE ME DAN UN DIRECTORIO Y TENGO Q COGER LOS FICHEROS QUE HAY DENTRO DE ESE DIRECTORIO DISTINGUIENDO SI SON DIRECTORIOS O FICHEROS Y MI PREGUNTA ES COMO HAGO ESTO. CREO Q ES CON ALGO DE STRUCT STAT PERO NO SE COMO COGER EL CAMPO QUE ME DIGA Q ES DIRECTORIO O FICHERO. GRACIAS
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:COMO SABER SI ES UN DIRECTORIO O NO???

Publicado por n0str0m0 (1503 intervenciones) el 18/05/2006 22:58:37
Depende, lo estás haciendo en C o con un shell script?

Salu2

PD: Si puedes, no escribas en mayúsculas, es que cuesta un montón leerlo ; )
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:COMO SABER SI ES UN DIRECTORIO O NO???

Publicado por joaquin (2 intervenciones) el 20/05/2006 12:07:38
hola pues estoy haciendo en C y necesito sacar los ficheros que hay dentro de un directorio y claro esta saber si son ficheros o no.
espero contestacion.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:COMO SABER SI ES UN DIRECTORIO O NO???

Publicado por n0str0m0 (1503 intervenciones) el 20/05/2006 13:55:13
En la página del manual de fstat te comentan que hay una macro llamada S_ISDIR. Utiliza esa.

Salu2
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:COMO SABER SI ES UN DIRECTORIO O NO???

Publicado por RE:fstat (1 intervención) el 11/10/2006 00:51:06
struct stat estado;

stat(path,&estado ) //no me acuerdo si toma eso exactamente
//podes usar fstat tambien que toma unn file descriptor devuelto por open

if(S_ISDIR(estado.st_mode)) //fijate si se llama st_mode pero algo asi era
printf("ES UN DIRECTORIO!!!);
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar