Xuanwo commented on code in PR #1892:
URL:
https://github.com/apache/incubator-opendal/pull/1892#discussion_r1161835975
##########
bindings/c/include/opendal.h:
##########
@@ -194,15 +205,57 @@ enum opendal_code
opendal_operator_blocking_write(opendal_operator_ptr op_ptr,
It is [safe] under two cases below
* The memory pointed to by `path` must contain a valid nul terminator at the
end of
the string.
- * The `path` points to NULL, this function simply returns you a nullptr
+ * The `path` points to NULL, this function simply returns you a nullptr for
`data`
+ and corresponding error code.
*/
struct opendal_result_read opendal_operator_blocking_read(opendal_operator_ptr
op_ptr,
const char *path);
+/*
+ Check whether the path exists.
+
+ If the operation succeeds, no matter the path exists or not,
+ the error code should be opendal_code::OPENDAL_OK. Otherwise,
+ the field `exist` is filled with false, and the error code
+ is set correspondingly.
+
+ # Safety
+
+ It is [safe] under two cases below
+ * The memory pointed to by `path` must contain a valid nul terminator at the
end of
+ the string.
+ * The `path` points to NULL, this function simply returns you a false for
field `exist`
+ and corresponding error code.
+ */
+struct opendal_result_exist opendal_operator_is_exist(opendal_operator_ptr
op_ptr,
+ const char *path);
+
+/*
+ Creates a new [`opendal_bytes`] from the raw pointer to the actual data and
its length.
+
+ The length and the data have to be consistent. If a longer len is provided,
invalid memory
+ access might happen. If a short len is provided, the data gets truncated.
+ */
+struct opendal_bytes opendal_bytes_new(uint8_t *bytes, uintptr_t len);
+
/*
Frees the heap memory used by the [`opendal_bytes`]
+
+ # Safety
+
+ Please make sure that the pointer is non-null and pointing at a valid [`Vec`].
+ */
+void opendal_bytes_free(const struct opendal_bytes *self);
+
+/*
+ Get the length of the data contained by `bytes`
+ */
+uintptr_t opendal_bytes_len_get(const struct opendal_bytes *self);
Review Comment:
Great catch! Thank you for the detailed explanation. Due to C's low-level
nature, we have to do additional work.
--
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]