aboutsummaryrefslogtreecommitdiff
path: root/zencore/filesystem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'zencore/filesystem.cpp')
-rw-r--r--zencore/filesystem.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/zencore/filesystem.cpp b/zencore/filesystem.cpp
index f6ea4824a..7cd71e4b4 100644
--- a/zencore/filesystem.cpp
+++ b/zencore/filesystem.cpp
@@ -436,11 +436,12 @@ CloneFile(std::filesystem::path FromPath, std::filesystem::path ToPath)
ScopedFd $From = { FromFd };
// The 'to' file
- int ToFd = open(ToPath.c_str(), O_WRONLY|O_CREAT|O_EXCL|O_CLOEXEC, 0666);
+ int ToFd = open(ToPath.c_str(), O_WRONLY|O_CREAT|O_EXCL|O_CLOEXEC);
if (ToFd < 0)
{
return false;
}
+ fchmod(ToFd, 0666);
ScopedFd $To = { FromFd };
ioctl(ToFd, FICLONE, FromFd);
@@ -502,11 +503,12 @@ CopyFile(std::filesystem::path FromPath, std::filesystem::path ToPath, const Cop
ScopedFd $From = {FromFd};
// To file
- int ToFd = open(ToPath.c_str(), O_WRONLY | O_CREAT | O_EXCL | O_CLOEXEC, 0666);
+ int ToFd = open(ToPath.c_str(), O_WRONLY | O_CREAT | O_EXCL | O_CLOEXEC);
if (ToFd < 0)
{
ThrowLastError(fmt::format("failed to create file {}", ToPath));
}
+ fchmod(ToFd, 0666);
ScopedFd $To = {ToFd};
// Copy impl
@@ -558,17 +560,19 @@ WriteFile(std::filesystem::path Path, const IoBuffer* const* Data, size_t Buffer
#else
int OpenFlags = O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC;
- int Fd = open(Path.c_str(), OpenFlags, 0666);
+ int Fd = open(Path.c_str(), OpenFlags);
if (Fd < 0)
{
zen::CreateDirectories(Path.parent_path());
- Fd = open(Path.c_str(), OpenFlags, 0666);
+ Fd = open(Path.c_str(), OpenFlags);
}
if (Fd < 0)
{
ThrowLastError(fmt::format("File open failed for '{}'", Path));
}
+
+ fchmod(Fd, 0666);
#endif
// TODO: this should be block-enlightened