Ji-Xinyou commented on code in PR #2416:
URL: 
https://github.com/apache/incubator-opendal/pull/2416#discussion_r1217739495


##########
bindings/c/tests/bdd.cpp:
##########
@@ -82,6 +82,14 @@ TEST_F(OpendalBddTest, FeatureTest)
     for (int i = 0; i < r.data->len; i++) {
         EXPECT_EQ(this->content[i], (char)(r.data->data[i]));
     }
+
+    // The blocking file should be deleted

Review Comment:
   The BDD test should strictly follow the feature defined in `bindings/test`, 
which does not require a delete operation. To test this, we may need to have 
separate unit tests, but not in the `BDD.cpp`.
   
   WDYT @Xuanwo 



##########
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

Review Comment:
   You need to change the comment as well



##########
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:
   I think you should add in the comment part that calling this function 
multiple times on the same path is safe. And it will return OPENDAL_OK if the 
path does not exist.



##########
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

Review Comment:
   "and you have written some contents into /testpath"



-- 
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