diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2019-03-29 10:24:51 +0100 |
---|---|---|
committer | José Bollo <jose.bollo@iot.bzh> | 2019-03-29 13:03:16 +0000 |
commit | 4de99dea9074944525a2148a13f62d3952de4909 (patch) | |
tree | 156f212bbd39a15e712dda565b32e31194da29ce | |
parent | 00490d7dee50a824c4fd3dddb20602b4b47bbc43 (diff) |
Test directory existence
Missing testing the readdir returned value.
Bug-AGL: SPEC-2288
Change-Id: I38691f2604ed4a13ff90e53dd5303e8ddcba7cf1
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
-rw-r--r-- | src/platform-info-binding.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/platform-info-binding.c b/src/platform-info-binding.c index c6bc9fd..c373d53 100644 --- a/src/platform-info-binding.c +++ b/src/platform-info-binding.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016, 2018 "IoT.bzh" + * Copyright (C) 2016-2019 "IoT.bzh" * * Author "Romain Forlot" <romain.forlot@iot.bzh> * @@ -86,7 +86,12 @@ void afv_subscribe(afb_req_t req) { int init(afb_api_t api) { struct dirent* dir_ent = NULL; + DIR* dir_handle = opendir(PLATFORM_INFO_DIR); + if (! dir_handle) { + AFB_ERROR("The directory %s does not exist.", PLATFORM_INFO_DIR); + return -1; + } json_object *json_file = json_object_new_object(), *current_file = NULL; while( (dir_ent = readdir(dir_handle)) != NULL) { |