jiaoew1991 commented on code in PR #2416:
URL: 
https://github.com/apache/incubator-opendal/pull/2416#discussion_r1217819875


##########
bindings/c/src/lib.rs:
##########
@@ -235,6 +235,56 @@ pub unsafe extern "C" fn opendal_operator_blocking_read(
     }
 }
 
+/// \brief Blockingly delete `path`.
+///
+/// Write the `bytes` into the `path` blockingly by `op_ptr`, returns the 
opendal_code OPENDAL_OK
+/// if succeeds, others otherwise
+///
+/// @param ptr The opendal_operator_ptr created previously
+/// @param path The designated path you want to delete
+/// @see opendal_operator_ptr
+/// @see opendal_code
+/// @return OPENDAL_OK if succeeds others otherwise
+///
+/// # Example
+///
+/// Following is an example
+/// ```C
+/// //...prepare your opendal_operator_ptr, named ptr for example
+///
+/// // now you can delete!
+/// opendal_code code = opendal_operator_blocking_delete(ptr, "/testpath");
+///
+/// // Assert that this succeeds
+/// assert(code == OPENDAL_OK)
+/// ```
+///
+/// # Safety
+///
+/// It is **safe** under the cases below
+/// * The memory pointed to by `path` must contain a valid nul terminator at 
the end of
+///   the string.
+///
+/// # Panic
+///
+/// * If the `path` points to NULL, this function panics, i.e. exits with 
information
+#[no_mangle]
+pub unsafe extern "C" fn opendal_operator_blocking_delete(
+    ptr: opendal_operator_ptr,
+    path: *const c_char,
+) -> opendal_code {
+    if path.is_null() {
+        panic!("The path given is pointing at NULL");
+    }
+
+    let op = ptr.as_ref();
+    let path = unsafe { std::ffi::CStr::from_ptr(path).to_str().unwrap() };
+    match op.delete(path) {
+        Ok(_) => opendal_code::OPENDAL_OK,

Review Comment:
   finished it 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to