/* * fs.rename */ static int fs_rename(lua_State* L) { FSR__SETUP const char *old_path = luaL_checkstring(L, 1); const char *new_path = luaL_checkstring(L, 2); FSR__SET_OPT_CB(3, on_fs_callback) uv_fs_rename(loop, req, old_path, new_path, cb); FSR__TEARDOWN }
JL_DLLEXPORT int jl_fs_rename(const char *src_path, const char *dst_path) { uv_fs_t req; JL_SIGATOMIC_BEGIN(); int ret = uv_fs_rename(jl_io_loop, &req, src_path, dst_path, NULL); uv_fs_req_cleanup(&req); JL_SIGATOMIC_END(); return ret; }
int os_rename(const char_u *path, const char_u *new_path) { uv_fs_t request; int result = uv_fs_rename(uv_default_loop(), &request, (const char *)path, (const char *)new_path, NULL); uv_fs_req_cleanup(&request); if (result == kLibuvSuccess) { return OK; } return FAIL; }
/* rename one file to another. */ void MVM_file_rename(MVMThreadContext *tc, MVMString *src, MVMString *dest) { char * const a = MVM_string_utf8_encode_C_string(tc, src); char * const b = MVM_string_utf8_encode_C_string(tc, dest); uv_fs_t req; if(uv_fs_rename(tc->loop, &req, a, b, NULL) < 0 ) { MVM_free(a); MVM_free(b); MVM_exception_throw_adhoc(tc, "Failed to rename file: %s", uv_strerror(req.result)); } MVM_free(a); MVM_free(b); }