From: Andrew Krieger Date: Wed, 28 Jun 2017 23:42:40 +0000 (-0700) Subject: Add `mode` parameter to FileUtil.h writeFile X-Git-Tag: v2017.07.03.00~21 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=30d05890f3e876a7094444c50cf652aba5026662;p=folly.git 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 --- 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; }