mirror of
https://github.com/hashcat/hashcat.git
synced 2025-06-26 18:02:39 +00:00
use recursive mkdir for the profile and the cache dir
This commit is contained in:
parent
954b7d0a4d
commit
40c68b8bf4
@ -37,5 +37,6 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char
|
|||||||
void folder_config_destroy (hashcat_ctx_t *hashcat_ctx);
|
void folder_config_destroy (hashcat_ctx_t *hashcat_ctx);
|
||||||
|
|
||||||
int hc_mkdir (const char *name, MAYBE_UNUSED const int mode);
|
int hc_mkdir (const char *name, MAYBE_UNUSED const int mode);
|
||||||
|
int hc_mkdir_rec (const char *path, MAYBE_UNUSED const int mode);
|
||||||
|
|
||||||
#endif // _FOLDER_H
|
#endif // _FOLDER_H
|
||||||
|
30
src/folder.c
30
src/folder.c
@ -9,6 +9,7 @@
|
|||||||
#include "event.h"
|
#include "event.h"
|
||||||
#include "shared.h"
|
#include "shared.h"
|
||||||
#include "folder.h"
|
#include "folder.h"
|
||||||
|
#include <libgen.h>
|
||||||
|
|
||||||
#if defined (__APPLE__)
|
#if defined (__APPLE__)
|
||||||
#include "event.h"
|
#include "event.h"
|
||||||
@ -394,8 +395,8 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins
|
|||||||
|
|
||||||
shared_dir = hcstrdup (shared_folder);
|
shared_dir = hcstrdup (shared_folder);
|
||||||
|
|
||||||
hc_mkdir (profile_dir, 0700);
|
hc_mkdir_rec (profile_dir, 0700);
|
||||||
hc_mkdir (cache_dir, 0700);
|
hc_mkdir_rec (cache_dir, 0700);
|
||||||
hc_mkdir (session_dir, 0700);
|
hc_mkdir (session_dir, 0700);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -567,3 +568,28 @@ int hc_mkdir (const char *name, MAYBE_UNUSED const int mode)
|
|||||||
return mkdir (name, mode);
|
return mkdir (name, mode);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int hc_mkdir_rec (const char *path, MAYBE_UNUSED const int mode)
|
||||||
|
{
|
||||||
|
char *subpath, *fullpath;
|
||||||
|
|
||||||
|
fullpath = hcstrdup (path);
|
||||||
|
subpath = dirname (fullpath);
|
||||||
|
if (strlen (subpath) > 1)
|
||||||
|
{
|
||||||
|
if (hc_mkdir_rec (subpath, mode) == -1) {
|
||||||
|
return -1;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hc_mkdir (path, mode) == -1)
|
||||||
|
{
|
||||||
|
if (errno != EEXIST)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hcfree (fullpath);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user