fgerlits commented on code in PR #1993:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1993#discussion_r2307229701


##########
core-framework/include/utils/Locations.h:
##########
@@ -0,0 +1,41 @@
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#include <filesystem>
+
+#include "Environment.h"
+#include "file/FileUtils.h"
+#include "Defaults.h"
+
+namespace org::apache::nifi::minifi::utils {
+inline std::string getDefaultExtensionsPattern() {
+  constexpr std::string_view DEFAULT_EXTENSION_PATH = "../extensions/*";
+  constexpr std::string_view DEFAULT_EXTENSION_PATH_RPM = RPM_LIB_DIR 
"/extensions/*";
+  if 
(Environment::getEnvironmentVariable(std::string(MINIFI_HOME_ENV_KEY).c_str()) 
== MINIFI_HOME_ENV_VALUE_FHS || file::get_executable_path().parent_path() == 
"/usr/bin") {
+    return std::string(DEFAULT_EXTENSION_PATH_RPM);
+  }
+  return std::string(DEFAULT_EXTENSION_PATH);
+}
+
+inline std::filesystem::path getMinifiDir() {
+  if 
(Environment::getEnvironmentVariable(std::string(MINIFI_HOME_ENV_KEY).c_str()) 
== MINIFI_HOME_ENV_VALUE_FHS || file::get_executable_path().parent_path() == 
"/usr/bin") {
+    return RPM_WORK_DIR;
+  }
+  return 
Environment::getEnvironmentVariable(std::string(MINIFI_HOME_ENV_KEY).c_str()).value_or("");
+}

Review Comment:
   I see, I missed the fact that we set the env.var.  But then if 
MINIFI_HOME_ENV_KEY is set (to something other than "" or "FHS"), then we 
should return its value from here, even if the executable is in `/usr/bin`, no?
   
   In fact, maybe we could always return 
`getEnvironmentVariable(std::string(MINIFI_HOME_ENV_KEY).c_str())`, since it 
was set in MinifiMain?



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