Commit 30d05890 authored by Andrew Krieger's avatar Andrew Krieger Committed by Facebook Github Bot

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
parent 05ce5228
...@@ -200,11 +200,13 @@ bool readFile( ...@@ -200,11 +200,13 @@ bool readFile(
* state will be unchanged on error. * state will be unchanged on error.
*/ */
template <class Container> template <class Container>
bool writeFile(const Container& data, const char* filename, bool writeFile(const Container& data,
int flags = O_WRONLY | O_CREAT | O_TRUNC) { const char* filename,
int flags = O_WRONLY | O_CREAT | O_TRUNC,
mode_t mode = 0666) {
static_assert(sizeof(data[0]) == 1, static_assert(sizeof(data[0]) == 1,
"writeFile works with element size equal to 1"); "writeFile works with element size equal to 1");
int fd = open(filename, flags, 0666); int fd = open(filename, flags, mode);
if (fd == -1) { if (fd == -1) {
return false; return false;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment