Código C:
Ver original
#include <stdlib.h> #include <stdio.h> #include <sys/types.h> #include <dirent.h> #include <string.h> #define PATH_PORTS "/usr/ports/" int main(int argc, char *argv[]) { DIR* PORTS_DIRECTORY; struct dirent *PORTS_FILES; char* PORTS; int PORTS_SIZE = 0; if ((PORTS_DIRECTORY = opendir(PATH_PORTS)) != NULL) { while ((PORTS_FILES = readdir(PORTS_DIRECTORY)) != NULL) { if (*PORTS_FILES->d_name == '.') { continue; }