From 30d05890f3e876a7094444c50cf652aba5026662 Mon Sep 17 00:00:00 2001 From: Andrew Krieger Date: Wed, 28 Jun 2017 16:42:40 -0700 Subject: [PATCH] Add `mode` parameter to FileUtil.h writeFile Summary: writeFileAtomic variants all have a mode, lets just hoist the mode parameter up and use what was hardcoded as the default. Reviewed By: Orvid Differential Revision: D5341481 fbshipit-source-id: 6976915dd73d2382b42bd991782730601b918978 --- folly/FileUtil.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/folly/FileUtil.h b/folly/FileUtil.h index 063fa238..7386b934 100644 --- a/folly/FileUtil.h +++ b/folly/FileUtil.h @@ -200,11 +200,13 @@ bool readFile( * state will be unchanged on error. */ template -bool writeFile(const Container& data, const char* filename, - int flags = O_WRONLY | O_CREAT | O_TRUNC) { +bool writeFile(const Container& data, + const char* filename, + int flags = O_WRONLY | O_CREAT | O_TRUNC, + mode_t mode = 0666) { static_assert(sizeof(data[0]) == 1, "writeFile works with element size equal to 1"); - int fd = open(filename, flags, 0666); + int fd = open(filename, flags, mode); if (fd == -1) { return false; } -- 2.34.1