#include <dlog/dlog.h>
#include <hal-common.h>
-#define DEFAULT_PLATFORM_MANIFEST_DIR "/etc/hal"
+#define DEFAULT_PLATFORM_MANIFEST_DIR "/etc/hal"
#define DEFAULT_HAL_INFO_INI "/hal/etc/hal-info.ini"
+#define DEFAULT_HAL_BACKEND_COMPATIBILITY_PATH "/opt/etc/hal/.hal-backend-compatibility"
#define HCC_BUF_MAX (256)
#define BOLD(STR) "\e[1m"STR"\e[m"
return found ? 0 : -EINVAL;
}
-// check result is exist, return true on exist.
-static bool result_exist(const char *dir)
+static bool result_exist(const char *path)
{
- // check result exists based on the directory 'dir'.
- return false;
+ return (access(path, F_OK) == 0);
}
static void show_help(void)
"\t-h, --help\n"
"\t\tshow this help.\n"
"\n"
- "\t--skip-if-result-exist[=DIRECTORY]\n"
+ "\t--skip-if-result-exist[=FILE]\n"
"\t\tskip compatibility check if there exists a result of compatibility.\n"
- "\t\tif DIRECTORY is given, locate a result based on the given DIRECTORY.\n"
+ "\t\tif FILE is given, locate a result based on the given FILE.\n"
"\n"
"\t--reset\n"
"\t\tremove the existing result file.\n"
int index;
bool skip_if_result_exist = false;
bool reset_file = false;
- const char *skip_if_result_exist_dir = NULL;
+ const char *skip_if_result_exist_path = NULL;
const char *platform_manifest_dir = NULL;
for (;;) {
switch (index) {
case OPT_SKIP_IF_RESULT_EXIST:
skip_if_result_exist = true;
- skip_if_result_exist_dir = optarg;
+ skip_if_result_exist_path = optarg ? : DEFAULT_HAL_BACKEND_COMPATIBILITY_PATH;
break;
case OPT_RESET:
reset_file = true;
return 0;
}
- if (skip_if_result_exist && result_exist(skip_if_result_exist_dir)) {
- printf("hal-compatibility-checker: skip checking\n");
+ if (reset_file) {
+ unlink(DEFAULT_HAL_BACKEND_COMPATIBILITY_PATH);
return 0;
}
- if (reset_file) {
- unlink("/opt/etc/hal/.hal-backend-compatibility");
+ if (skip_if_result_exist && result_exist(skip_if_result_exist_path)) {
+ dlog_print(DLOG_DEBUG, LOG_TAG_HAL_COMPATIBILITY_CHECKER,
+ "hal-compatibility-checker: skip checking\n");
return 0;
}