diff --git a/include/folder.h b/include/folder.h index 6d98c92c1..5d3ce074f 100644 --- a/include/folder.h +++ b/include/folder.h @@ -21,15 +21,12 @@ #if defined (_WIN) #include +#include #endif #define DOT_HASHCAT ".hashcat" #define SESSIONS_FOLDER "sessions" -#if defined (_WIN) -#define mkdir(name,mode) mkdir (name) -#endif - int sort_by_stringptr (const void *p1, const void *p2); char *get_exec_path (void); @@ -43,3 +40,5 @@ char **scan_directory (const char *path); int folder_config_init (folder_config_t *folder_config, const char *install_folder, const char *shared_folder); void folder_config_destroy (folder_config_t *folder_config); + +int hc_mkdir (const char *name, int mode); diff --git a/src/folder.c b/src/folder.c index bfd444116..514b0ce37 100644 --- a/src/folder.c +++ b/src/folder.c @@ -294,8 +294,8 @@ int folder_config_init (folder_config_t *folder_config, const char *install_fold session_dir = get_session_dir (profile_dir); shared_dir = mystrdup (shared_folder); - mkdir (profile_dir, 0700); - mkdir (session_dir, 0700); + hc_mkdir (profile_dir, 0700); + hc_mkdir (session_dir, 0700); } else { @@ -391,7 +391,7 @@ int folder_config_init (folder_config_t *folder_config, const char *install_fold snprintf (kernels_folder, HCBUFSIZ_TINY - 1, "%s/kernels", profile_dir); - mkdir (kernels_folder, 0700); + hc_mkdir (kernels_folder, 0700); myfree (kernels_folder); @@ -424,3 +424,13 @@ void folder_config_destroy (folder_config_t *folder_config) myfree (folder_config); } + +int hc_mkdir (const char *name, int mode) +{ + #if defined (_WIN) + if (mode == 0) mode = 0; // makes compiler happy + return _mkdir (name); + #else + return mkdir (name, mode); + #endif +} diff --git a/src/induct.c b/src/induct.c index 1592b90b5..3b0719dfa 100644 --- a/src/induct.c +++ b/src/induct.c @@ -72,7 +72,7 @@ int induct_ctx_init (induct_ctx_t *induct_ctx, const user_options_t *user_option } } - if (mkdir (root_directory, 0700) == -1) + if (hc_mkdir (root_directory, 0700) == -1) { log_error ("ERROR: %s: %s", root_directory, strerror (errno)); diff --git a/src/outfile_check.c b/src/outfile_check.c index 89bea33e9..3f6b0e8b5 100644 --- a/src/outfile_check.c +++ b/src/outfile_check.c @@ -361,7 +361,7 @@ int outcheck_ctx_init (outcheck_ctx_t *outcheck_ctx, const user_options_t *user_ } else { - if (mkdir (outcheck_ctx->root_directory, 0700) == -1) + if (hc_mkdir (outcheck_ctx->root_directory, 0700) == -1) { log_error ("ERROR: %s: %s", outcheck_ctx->root_directory, strerror (errno));