Create directory with 0777 mode in make_directory

Fixes #408
This commit is contained in:
Maxime Coste 2015-09-16 20:04:29 +01:00
parent 693d9a4861
commit c859e8ab5f

View File

@ -304,10 +304,16 @@ void make_directory(StringView dir)
if (not S_ISDIR(st.st_mode)) if (not S_ISDIR(st.st_mode))
throw runtime_error(format("Cannot make directory, '{}' exists but is not a directory", dirname)); throw runtime_error(format("Cannot make directory, '{}' exists but is not a directory", dirname));
} }
else if (mkdir(dirname.zstr(), S_IRWXU) != 0) else
{
auto old_mask = umask(0);
auto restore_mask = on_scope_end([old_mask]() { umask(old_mask); });
if (mkdir(dirname.zstr(), S_IRWXU | S_IRWXG | S_IRWXO) != 0)
throw runtime_error(format("mkdir failed for directory '{}' errno {}", dirname, errno)); throw runtime_error(format("mkdir failed for directory '{}' errno {}", dirname, errno));
} }
} }
}
template<typename Filter> template<typename Filter>
Vector<String> list_files(StringView prefix, StringView dirname, Vector<String> list_files(StringView prefix, StringView dirname,