This is an automated email from the ASF dual-hosted git repository.

xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal.git


The following commit(s) were added to refs/heads/main by this push:
     new 09fb97287a feat(bindings/cpp): rename is_exist to exists as core did 
(#5198)
09fb97287a is described below

commit 09fb97287af5c2bbbc9937a3eee05c18b6fa6b1a
Author: Twice <[email protected]>
AuthorDate: Fri Oct 18 09:47:39 2024 +0800

    feat(bindings/cpp): rename is_exist to exists as core did (#5198)
---
 bindings/cpp/include/opendal.hpp  | 9 +++++++++
 bindings/cpp/src/lib.rs           | 6 +++---
 bindings/cpp/src/opendal.cpp      | 6 +++++-
 bindings/cpp/tests/basic_test.cpp | 6 +++---
 4 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/bindings/cpp/include/opendal.hpp b/bindings/cpp/include/opendal.hpp
index 714cba7b9a..cbf96476dd 100644
--- a/bindings/cpp/include/opendal.hpp
+++ b/bindings/cpp/include/opendal.hpp
@@ -137,8 +137,17 @@ class Operator {
    * @param path The path to check
    * @return true if the path exists, false otherwise
    */
+  [[deprecated("Use exists() instead.")]]
   bool is_exist(std::string_view path);
 
+  /**
+   * @brief Check if the path exists
+   *
+   * @param path The path to check
+   * @return true if the path exists, false otherwise
+   */
+  bool exists(std::string_view path);
+
   /**
    * @brief Create a directory
    *
diff --git a/bindings/cpp/src/lib.rs b/bindings/cpp/src/lib.rs
index f8b4a77d25..a37807c078 100644
--- a/bindings/cpp/src/lib.rs
+++ b/bindings/cpp/src/lib.rs
@@ -80,7 +80,7 @@ mod ffi {
         fn new_operator(scheme: &str, configs: Vec<HashMapValue>) -> 
Result<Box<Operator>>;
         fn read(self: &Operator, path: &str) -> Result<Vec<u8>>;
         fn write(self: &Operator, path: &str, bs: &'static [u8]) -> Result<()>;
-        fn is_exist(self: &Operator, path: &str) -> Result<bool>;
+        fn exists(self: &Operator, path: &str) -> Result<bool>;
         fn create_dir(self: &Operator, path: &str) -> Result<()>;
         fn copy(self: &Operator, src: &str, dst: &str) -> Result<()>;
         fn rename(self: &Operator, src: &str, dst: &str) -> Result<()>;
@@ -125,8 +125,8 @@ impl Operator {
         Ok(self.0.write(path, bs)?)
     }
 
-    fn is_exist(&self, path: &str) -> Result<bool> {
-        Ok(self.0.is_exist(path)?)
+    fn exists(&self, path: &str) -> Result<bool> {
+        Ok(self.0.exists(path)?)
     }
 
     fn create_dir(&self, path: &str) -> Result<()> {
diff --git a/bindings/cpp/src/opendal.cpp b/bindings/cpp/src/opendal.cpp
index 01bb99813d..c886647cb0 100644
--- a/bindings/cpp/src/opendal.cpp
+++ b/bindings/cpp/src/opendal.cpp
@@ -52,8 +52,12 @@ void Operator::write(std::string_view path, const 
std::vector<uint8_t> &data) {
       RUST_STR(path), rust::Slice<const uint8_t>(data.data(), data.size()));
 }
 
+bool Operator::exists(std::string_view path) {
+  return operator_.value()->exists(RUST_STR(path));
+}
+
 bool Operator::is_exist(std::string_view path) {
-  return operator_.value()->is_exist(RUST_STR(path));
+  return exists(path);
 }
 
 void Operator::create_dir(std::string_view path) {
diff --git a/bindings/cpp/tests/basic_test.cpp 
b/bindings/cpp/tests/basic_test.cpp
index 8e82eb5a93..9ffd03df33 100644
--- a/bindings/cpp/tests/basic_test.cpp
+++ b/bindings/cpp/tests/basic_test.cpp
@@ -62,11 +62,11 @@ TEST_F(OpendalTest, BasicTest) {
   EXPECT_EQ(res, data);
 
   // is_exist
-  EXPECT_TRUE(op.is_exist(file_path));
+  EXPECT_TRUE(op.exists(file_path));
 
   // create_dir
   op.create_dir(dir_path);
-  EXPECT_TRUE(op.is_exist(dir_path));
+  EXPECT_TRUE(op.exists(dir_path));
 
   // stat
   auto metadata = op.stat(file_path);
@@ -88,7 +88,7 @@ TEST_F(OpendalTest, BasicTest) {
   // remove
   op.remove(file_path_renamed);
   op.remove(dir_path);
-  EXPECT_FALSE(op.is_exist(file_path_renamed));
+  EXPECT_FALSE(op.exists(file_path_renamed));
 }
 
 TEST_F(OpendalTest, ReaderTest) {

Reply via email to