All pastes #475659 Raw Edit

Untitled

public c v1 · immutable
·published 2007-05-07 16:17 UTC
rendered paste body
#include <sys/types.h>#include <sys/dir.h>#include <sys/param.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h> #define FALSE 0#define TRUE !FALSE extern  int alphasort(); char pathname[MAXPATHLEN]; int main(int argc, char * argv[])   {	int count,i;	struct direct **files;	int file_select(struct direct   *entry);		if (getwd(pathname) == NULL ){ 		printf("Error obteniendo ruta path$\backslash$n");		exit(0);	}		printf("Directorio Actual = %s\n",pathname);	count = scandir(pathname, &files, file_select, alphasort);	/* Si no se encuentran fichero, hacer items no seleccionables */	if(count <= 0){		printf("No hay ficheros en directorio\n");		exit(0);	}		printf("Cantidad de ficheros = %d\n",count);		for (i=1;i<count+1;++i)		printf("%s  \n",files[i-1]->d_name);			printf("\n"); /* flush buffer */		return 0;}  int file_select(struct direct   *entry){ 	if ((strcmp(entry->d_name, ".") == 0) || (strcmp(entry->d_name, "..") == 0))			return (FALSE);	else		return (TRUE);}