Skip to content

Commit cd5f31e

Browse files
committed
fix(api): accept empty string as root folder path in move/copy operations
vxcore_node_move and vxcore_node_copy now convert empty dest_parent_path to "." for root folder targeting while still rejecting nullptr as invalid.
1 parent ac61862 commit cd5f31e

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/api/vxcore_node_api.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,12 @@ VXCORE_API VxCoreError vxcore_node_move(VxCoreContextHandle context, const char
177177
return VXCORE_ERR_INVALID_PARAM;
178178
}
179179

180+
// Convert empty dest_parent_path to "." for root folder
181+
std::string dest_path = dest_parent_path;
182+
if (dest_path.empty()) {
183+
dest_path = ".";
184+
}
185+
180186
vxcore::VxCoreContext *ctx = reinterpret_cast<vxcore::VxCoreContext *>(context);
181187

182188
try {
@@ -201,9 +207,9 @@ VXCORE_API VxCoreError vxcore_node_move(VxCoreContextHandle context, const char
201207

202208
// Move based on type
203209
if (node_type == vxcore::NodeType::File) {
204-
return folder_manager->MoveFile(src_path, dest_parent_path);
210+
return folder_manager->MoveFile(src_path, dest_path);
205211
} else {
206-
return folder_manager->MoveFolder(src_path, dest_parent_path);
212+
return folder_manager->MoveFolder(src_path, dest_path);
207213
}
208214
} catch (const std::exception &e) {
209215
ctx->last_error = std::string("Exception: ") + e.what();
@@ -218,6 +224,12 @@ VXCORE_API VxCoreError vxcore_node_copy(VxCoreContextHandle context, const char
218224
return VXCORE_ERR_INVALID_PARAM;
219225
}
220226

227+
// Convert empty dest_parent_path to "." for root folder
228+
std::string dest_path = dest_parent_path;
229+
if (dest_path.empty()) {
230+
dest_path = ".";
231+
}
232+
221233
vxcore::VxCoreContext *ctx = reinterpret_cast<vxcore::VxCoreContext *>(context);
222234

223235
try {
@@ -245,9 +257,9 @@ VXCORE_API VxCoreError vxcore_node_copy(VxCoreContextHandle context, const char
245257

246258
// Copy based on type
247259
if (node_type == vxcore::NodeType::File) {
248-
err = folder_manager->CopyFile(src_path, dest_parent_path, target_name, node_id);
260+
err = folder_manager->CopyFile(src_path, dest_path, target_name, node_id);
249261
} else {
250-
err = folder_manager->CopyFolder(src_path, dest_parent_path, target_name, node_id);
262+
err = folder_manager->CopyFolder(src_path, dest_path, target_name, node_id);
251263
}
252264

253265
if (err != VXCORE_OK) {

0 commit comments

Comments
 (0)