nissy-core

The "engine" of nissy, including the H48 optimal solver.
git clone https://git.tronto.net/nissy-core
Download | Log | Files | Refs | README | LICENSE

commit 2ac46cb4d4133e5d5de90bacfc9b6e979d1d6046
parent 895a8ec484ead49ab243772895b24b787e94ef0e
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date:   Sun,  1 Mar 2026 18:32:49 +0100

Shell improvements

Ask before overwriting a table file.

Diffstat:
Mshell/shell.c | 15++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/shell/shell.c b/shell/shell.c @@ -10,6 +10,7 @@ #include "../src/nissy.h" +#define INPUT_BUFFER_SIZE UINT64_C(1024) #define PRINTCUBE_BUFFER_SIZE UINT64_C(1024) #define SOLUTIONS_BUFFER_SIZE UINT64_C(500000) #define MAX_PATH_LENGTH UINT64_C(10000) @@ -328,6 +329,7 @@ gendata_exec(args_t *args) int i; FILE *file; char path[MAX_PATH_LENGTH], dataid[NISSY_SIZE_DATAID]; + char r[INPUT_BUFFER_SIZE]; unsigned char *buf; int64_t ret, size; size_t written; @@ -340,10 +342,21 @@ gendata_exec(args_t *args) return -3; } - /* TODO: should give warning if overwriting existing file */ for (i = 0; tablepaths[i] != NULL; i++) { strcpy(path, tablepaths[i]); strcat(path, dataid); + + if ((file = fopen(path, "rb")) != NULL) { + fclose(file); + fprintf(stderr, "gendata: file %s already exists, " + "overwrite? [Y/n] ", path); + fgets(r, INPUT_BUFFER_SIZE, stdin); + if (r[0] != '\n' && r[0] != 'Y' && r[0] != 'y') { + fprintf(stderr, "gendata: aborting.\n"); + return -1; + } + } + file = fopen(path, "wb"); if (file != NULL) break;