diff --git a/Common/File/FileUtil.cpp b/Common/File/FileUtil.cpp index 46b92dac24..f978425458 100644 --- a/Common/File/FileUtil.cpp +++ b/Common/File/FileUtil.cpp @@ -703,7 +703,9 @@ bool CreateDir(const Path &path, bool quiet) { } return false; #else - if (mkdir(path.ToString().c_str(), 0755) == 0) { + if (mkdir(path.ToString().c_str(), 0775) == 0) { + // mkdir's mode is masked by the umask, chmod's isn't. + chmod(path.ToString().c_str(), 0775); return true; } @@ -712,6 +714,11 @@ bool CreateDir(const Path &path, bool quiet) { if (!quiet) { DEBUG_LOG(Log::IO, "CreateDir: mkdir failed on %s: already exists", path.c_str()); } + // Repair directories created with older, narrower permissions. + struct stat info; + if (stat(path.c_str(), &info) == 0 && S_ISDIR(info.st_mode)) { + chmod(path.c_str(), 0775); + } return true; }