Since the "realpath" function is not available in the Windows operating system, the "getRealpath" function has been added and replaced so that it can be used in the Windows operating system.
- Add "getRealpath" function to utils.
**Self evaluation:**
1. Build test: [x]Passed []Failed []Skipped
2. Run test: [x]Passed []Failed []Skipped
Signed-off-by: Seungbaek Hong <sb92.hong@samsung.net>
}
closedir(dir);
- char *ret = realpath(base.c_str(), nullptr);
+ char *ret = getRealpath(base.c_str(), nullptr);
if (ret == nullptr) {
std::stringstream ss;
model_file_context = std::make_unique<AppContext>();
- auto config_realpath_char = realpath(config.c_str(), nullptr);
+ auto config_realpath_char = getRealpath(config.c_str(), nullptr);
if (config_realpath_char == nullptr) {
ml_loge("failed to resolve config path to absolute path, reason: %s",
strerror(errno));
*
*/
+#ifdef _WIN32
+#define MAX_PATH_LENGTH 1024
+#endif
+
#include <cmath>
#include <fstream>
#include <random>
});
}
+char *getRealpath(const char *name, char *resolved) {
+#ifdef _WIN32
+ return _fullpath(resolved, name, MAX_PATH_LENGTH);
+#else
+ return realpath(name, resolved);
+#endif
+}
+
} // namespace nntrainer
return static_cast<T>(i1 | i2);
}
+/**
+ * @brief Convert a relative path into an absolute path.
+ *
+ * @param name relative path
+ * @param resolved variable to store the result value.
+ *
+ * @return absolute path
+ */
+char *getRealpath(const char *name, char *resolved);
+
} /* namespace nntrainer */
#endif /* __cplusplus */