zeroshade commented on code in PR #2918:
URL: https://github.com/apache/arrow-adbc/pull/2918#discussion_r2129221206


##########
go/adbc/drivermgr/adbc_driver_manager.cc:
##########
@@ -114,7 +125,187 @@ struct OwnedError {
   }
 };
 
+std::filesystem::path UserConfigDir() {
+  std::filesystem::path config_dir;
+#if defined(_WIN32)
+  auto dir = std::getenv("AppData");
+  if (dir) {
+    config_dir = std::filesystem::path(dir);
+    config_dir /= "ADBC/drivers";
+  }
+#elif defined(__APPLE__)
+  auto dir = std::getenv("HOME");
+  if (dir) {
+    config_dir = std::filesystem::path(dir);
+    config_dir /= "Library/Application Support/ADBC";
+  }
+#elif defined(__linux__)
+  auto dir = std::getenv("XDG_CONFIG_HOME");
+  if (!dir) {
+    dir = std::getenv("HOME");
+    if (dir) {
+      config_dir = std::filesystem::path(dir);
+    }
+  } else {
+    config_dir = std::filesystem::path(dir);
+  }
+
+  if (!config_dir.empty()) {
+    config_dir /= "adbc";
+  }
+#endif
+
+  return config_dir;
+}
+
 // Driver state
+struct DriverInfo {
+  std::string manifest_file;
+  std::string driver_name;
+  std::string lib_path;
+  std::string entrypoint;
+
+  std::string version;
+  std::string source;
+};
+
+#ifdef _WIN32
+class RegistryKey {
+ public:
+  RegistryKey(HKEY root, const std::string_view subkey) noexcept
+      : root_(root), key_(nullptr), is_open_(false) {
+    auto result = RegOpenKeyExA(root_, subkey.data(), 0, KEY_READ, &key_);
+    is_open_ = (result == ERROR_SUCCESS);
+  }
+
+  ~RegistryKey() {
+    if (is_open_ && key_ != nullptr) {
+      RegCloseKey(key_);
+      key_ = nullptr;
+      is_open_ = false;
+    }
+  }
+
+  HKEY key() const { return key_; }
+  bool is_open() const { return is_open_; }
+
+  std::string GetString(const std::string& name, const std::string& 
default_value = "") {

Review Comment:
   I can understand changing it to not have a default value, but is the intent 
of passing by value there just so we can potentially elide the copy for the 
return via move semantics?



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