END_TEST START_TEST(test_getContentSummary) { bool s; struct hdfs_object *e = NULL, *cs; const char *tf = "/HADOOFUS_TEST_CSDIR"; s = hdfs_mkdirs(h, tf, 0755, &e); if (e) ck_abort_msg("exception: %s", hdfs_exception_get_message(e)); ck_assert_msg(s, "mkdirs returned false"); cs = hdfs_getContentSummary(h, tf, &e); if (e) ck_abort_msg("exception: %s", hdfs_exception_get_message(e)); ck_assert(!hdfs_object_is_null(cs)); hdfs_object_free(cs); s = hdfs_delete(h, tf, false/*recurse*/, &e); if (e) ck_abort_msg("exception: %s", hdfs_exception_get_message(e)); ck_assert_msg(s, "delete returned false"); }
/** * hdfsCreateDirectory - Make the given file and all non-existent * parents into directories. * * @param fs The configured filesystem handle. * @param path The path of the directory. * @return Returns 0 on success, -1 on error. */ int hdfsCreateDirectory(hdfsFS fs, const char* path) { int res = 0; struct hdfsFS_internal *client = fs; struct hdfs_object *ex = NULL; char *path_abs = _makeabs(fs, path); bool b = hdfs_mkdirs(client->fs_namenode, path_abs, 0755, &ex); if (ex) { ERR(EIO, "mkdirs(): %s", hdfs_exception_get_message(ex)); hdfs_object_free(ex); res = -1; goto out; } if (!b) { ERR(EINVAL, "CreateDirectory() failed on '%s'", path_abs); res = -1; goto out; } out: if (path_abs != path) free(path_abs); return res; }
END_TEST START_TEST(test_mkdirs) { bool s; struct hdfs_object *e = NULL; const char *tf = "/HADOOFUS_TEST_MKDIRS"; s = hdfs_mkdirs(h, tf, 0755, &e); if (e) ck_abort_msg("exception: %s", hdfs_exception_get_message(e)); ck_assert_msg(s, "mkdirs returned false"); s = hdfs_delete(h, tf, false/*recurse*/, &e); if (e) ck_abort_msg("exception: %s", hdfs_exception_get_message(e)); ck_assert_msg(s, "delete returned false"); }