aboutsummaryrefslogtreecommitdiff
path: root/src/list_pkgs.c
blob: 5d6fccefb3be6cddd26b79e8c974566d0aa7f3ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <dirent.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>

#include "lua_state.h"
#include "vars.h"

void list_pkgs() {
  char* src_code = map_get(&cached_install_directories, "src");
  struct dirent* dirent_ptr;
  DIR* dir_ptr = opendir(src_code);

  if (dir_ptr == NULL) {
    fprintf(stderr, "%scould not open %s\n", print_pkgit, src_code);
    return;
  }

  while ((dirent_ptr = readdir(dir_ptr)) != NULL) {
    if (strcmp(dirent_ptr->d_name, "..") == 0 || strcmp(dirent_ptr->d_name, ".") == 0) { continue; }
    printf("%s\n", dirent_ptr->d_name);
  }
}