mirror of https://github.com/schoebel/mars
generic: avoid unnecessary mkdir()
This commit is contained in:
parent
93e829f94e
commit
07acef8d1d
|
@ -1097,6 +1097,7 @@ int ordered_symlink(const char *oldpath,
|
||||||
|
|
||||||
/* Automatically create any missing path dirs */
|
/* Automatically create any missing path dirs */
|
||||||
while (unlikely(status < 0 && status != -EEXIST)) {
|
while (unlikely(status < 0 && status != -EEXIST)) {
|
||||||
|
struct kstat test = {};
|
||||||
int old_len;
|
int old_len;
|
||||||
int check;
|
int check;
|
||||||
|
|
||||||
|
@ -1117,6 +1118,10 @@ int ordered_symlink(const char *oldpath,
|
||||||
dir_len--;
|
dir_len--;
|
||||||
if (dir_len <= 0 || dir_len >= old_len)
|
if (dir_len <= 0 || dir_len >= old_len)
|
||||||
break;
|
break;
|
||||||
|
/* do not try to tackle existing dir_path */
|
||||||
|
check = mars_stat(dir_path, &test, true);
|
||||||
|
if (check >= 0 && S_ISDIR(test.mode))
|
||||||
|
break;
|
||||||
/* create the interim dir */
|
/* create the interim dir */
|
||||||
check = mars_mkdir(dir_path);
|
check = mars_mkdir(dir_path);
|
||||||
if (check >= 0) {
|
if (check >= 0) {
|
||||||
|
|
Loading…
Reference in New Issue