Skip to content

Commit

Permalink
Path check, when creating stack
Browse files Browse the repository at this point in the history
  • Loading branch information
niess committed Sep 5, 2023
1 parent c1c8a82 commit f5c8ef8
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/turtle/stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,13 @@ enum turtle_return turtle_stack_create(struct turtle_stack ** stack,
double lat_delta = 0., long_delta = 0.;
int data_size = strlen(path) + 1;

int rc;
tinydir_dir dir;
for (rc = tinydir_open(&dir, path); (rc == 0) && dir.has_next;
tinydir_next(&dir)) {
int rc = tinydir_open(&dir, path);
if (rc != 0) {
return TURTLE_ERROR_FORMAT(
TURTLE_RETURN_PATH_ERROR, "could not access %s", path);
}
for (; dir.has_next; tinydir_next(&dir)) {
tinydir_file file;
tinydir_readfile(&dir, &file);
if (file.is_dir) continue;
Expand Down Expand Up @@ -119,7 +122,7 @@ enum turtle_return turtle_stack_create(struct turtle_stack ** stack,
tinydir_close(&dir);
return TURTLE_ERROR_RAISE();
}
if (rc == 0) tinydir_close(&dir);
tinydir_close(&dir);

/* Check the grid size */
int lat_n = 0, long_n = 0;
Expand Down

0 comments on commit f5c8ef8

Please # to comment.