From c06625a00e1e8af7615f6c3c35f77f3fd25d58db Mon Sep 17 00:00:00 2001 From: John Jones Date: Wed, 20 Sep 2017 11:30:39 -0500 Subject: [PATCH] Fixing building the paths for tests --- test/test_helper.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/test/test_helper.c b/test/test_helper.c index 67a0e1e..3c7173f 100644 --- a/test/test_helper.c +++ b/test/test_helper.c @@ -172,6 +172,23 @@ int drop_repository(const char* path) { return 1; } +static void _mkdir(const char *dir, const mode_t mode) { + char tmp[256]; + char *p = NULL; + size_t len; + + snprintf(tmp, sizeof(tmp),"%s",dir); + len = strlen(tmp); + if(tmp[len - 1] == '/') + tmp[len - 1] = 0; + for(p = tmp + 1; *p; p++) + if(*p == '/') { + *p = 0; + mkdir(tmp, mode); + *p = '/'; + } + mkdir(tmp, S_IRWXU); +} /** * drops and builds a repository at the specified path * @param path the path @@ -187,7 +204,7 @@ int drop_and_build_repository(const char* path, int swarm_port, struct Libp2pVec return 0; } } - mkdir(path, S_IRWXU); + _mkdir(path, S_IRWXU); return make_ipfs_repository(path, swarm_port, bootstrap_peers, peer_id); }