PengZheng commented on code in PR #476:
URL: https://github.com/apache/celix/pull/476#discussion_r1155527804


##########
libs/framework/include/celix/Bundle.h:
##########
@@ -74,6 +80,43 @@ namespace celix {
         }
 #endif
 
+       /**
+        * @brief Return a use-able entry path for the provided relative path 
to a bundle persistent storage.
+        *
+        * For example if there is a resource entry in the bundle persistent 
storage at path 'resources/counters.txt` this call
+        * will return a relative path to entry in the bundle persistent 
storage.
+        * .cache/bundle5/storage/resources/counters.txt
+        *
+        * A provided path is always relative to the bundle persistent storage 
root and can start with a "/".
+        * A provided path NULL, "", "." or "/" indicates the root of this 
bundle cache store.
+        *
+        * The returned entry path should can be treated as read-write.
+        *
+        * @param path The relative path to a bundle persistent storage entry.
+        * @return The use-able entry path or an empty string if the entry is 
not found.
+        */
+#if __cplusplus >= 201703L //C++17 or higher
+        [[nodiscard]] std::string getDataFile(std::string_view path) const {
+            std::string result{};
+            char* entry = celix_bundle_getDataFile(cBnd.get(), path.data());
+            if (entry != nullptr) {
+                result = std::string{entry};
+                free(entry);

Review Comment:
   Raw resource not managed by RAII is not exception-safe. 



-- 
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: dev-unsubscr...@celix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to