From ecd8bbf2c0b7a4ca20c9cdc5f8f26836d4082c36 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Thu, 3 Mar 2022 19:02:08 +0100 Subject: Added messages about generating pruning tables --- src/shell.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/shell.c') diff --git a/src/shell.c b/src/shell.c index 6e67e0a..31dde0e 100644 --- a/src/shell.c +++ b/src/shell.c @@ -3,6 +3,27 @@ static void cleanwhitespaces(char *line); static int parseline(char *line, char **v); +bool +checkfiles() +{ + /* TODO: add more checks (other files, use checksum...) */ + FILE *f; + char fname[strlen(tabledir)+100]; + int i; + + for (i = 0; allpd[i] != NULL; i++) { + strcpy(fname, tabledir); + strcpy(fname, "/"); + strcpy(fname, allpd[i]->filename); + if ((f = fopen(fname, "rb")) == NULL) + return false; + else + fclose(f); + } + + return true; +} + static void cleanwhitespaces(char *line) { @@ -119,6 +140,19 @@ launch(bool batchmode) int main(int argc, char *argv[]) { + init_env(); + + if (!checkfiles()) { + fprintf(stderr, + "--- Warning ---\n" + "Some pruning tables are missing or unreadable." + "You can generate them with `nissy gen -t 4'\n" + "Here `4' is the number of threads. Use more if your" + "CPU has them, or expect it to take a while.\n" + "---------------\n\n" + ); + } + if (argc > 1) { if (!strcmp(argv[1], "-b")) { launch(true); -- cgit v1.3