All pastes #292228 Raw Edit

Anonyme

public text v1 · immutable
#292228 ·published 2006-12-26 08:34 UTC
rendered paste body
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <dirent.h>
#include <sys/stat.h>
#include <assert.h>
#include <errno.h>
void parse(char* sourcerep) {
	struct dirent* dossiers = NULL;
	DIR* dossier = NULL;
	struct stat infos;
	dossier = opendir(sourcerep);
	while ((dossiers = readdir(dossier)) != NULL) {
		stat(dossiers->d_name, &infos);
		if (S_ISDIR(infos.st_mode)) {
//			char* commande = NULL;
			if (strcmp(dossiers->d_name, ".") == 0 || strcmp(dossiers->d_name, "..") == 0) continue;

			printf("Repertoire: %s\n", dossiers->d_name);
//			chdir(dossiers->d_name);
			parse(dossiers->d_name);
			//chdir("..");
			//fprintf (stderr, "Erreur: %s.\n", strerror(errno) );
		} else {

			printf("Fichier: %s\n", dossiers->d_name);
		}
	}
	closedir(dossier);
}


int main(void) {
	parse("/");
	return EXIT_SUCCESS;