diff --git a/src/vy_adapter.cpp b/src/vy_adapter.cpp index dd66dfb4..49e186dc 100644 --- a/src/vy_adapter.cpp +++ b/src/vy_adapter.cpp @@ -135,6 +135,30 @@ vy_in_session(uint64_t handle) return h->inSession() ? 1 : 0; } +const char * +vy_validate_path(uint64_t handle, const void** path_ptr, size_t len) +{ + Cstore *cstore = cstore_of_handle(handle); + const char **path = (const char **) path_ptr; + Cpath path_comps = Cpath(path, len); + const char *out_data; + std::string out_str = ""; + int res; + + out_stream = stdout; + stdout_redirect redirect = stdout_redirect(); + + res = cstore->validateSetPath(path_comps); + if (!res) { + out_str = "\nInvalid set path: " + path_comps.to_string() + "\n"; + out_str.append(redirect.get_redirected_output()); + } + + out_data = out_data_copy(out_str); + out_stream = NULL; + return out_data; +} + const char * vy_set_path(uint64_t handle, const void** path_ptr, size_t len) { @@ -148,6 +172,30 @@ vy_set_path(uint64_t handle, const void** path_ptr, size_t len) out_stream = stdout; stdout_redirect redirect = stdout_redirect(); + res = cstore->setCfgPath(path_comps); + if (!res) { + out_str = "\nSet config path failed: " + path_comps.to_string() + "\n"; + out_str.append(redirect.get_redirected_output()); + } + + out_data = out_data_copy(out_str); + out_stream = NULL; + return out_data; +} + +const char * +vy_legacy_set_path(uint64_t handle, const void** path_ptr, size_t len) +{ + Cstore *cstore = cstore_of_handle(handle); + const char **path = (const char **) path_ptr; + Cpath path_comps = Cpath(path, len); + const char *out_data; + std::string out_str = ""; + int res; + + out_stream = stdout; + stdout_redirect redirect = stdout_redirect(); + res = cstore->validateSetPath(path_comps); if (!res) { out_str = "\nInvalid set path: " + path_comps.to_string() + "\n"; diff --git a/src/vy_adapter.h b/src/vy_adapter.h index fba6368c..636c303a 100644 --- a/src/vy_adapter.h +++ b/src/vy_adapter.h @@ -22,7 +22,9 @@ extern "C" { uint64_t vy_cstore_init(void); void vy_cstore_free(uint64_t); int vy_in_session(uint64_t); +const char *vy_validate_path(uint64_t, const void **, size_t); const char *vy_set_path(uint64_t, const void **, size_t); +const char *vy_legacy_set_path(uint64_t, const void **, size_t); const char *vy_delete_path(uint64_t, const void **, size_t); #ifdef __cplusplus