EventCountTest cleanups
[folly.git] / folly / FileUtil.h
index d674dc2e1e4b62acbdb7d1107aec60ca9a386ff8..2679f928f1add40886c1e3dfb0b1fe1a23134d08 100644 (file)
@@ -17,9 +17,9 @@
 #ifndef FOLLY_FILEUTIL_H_
 #define FOLLY_FILEUTIL_H_
 
-#include "folly/Conv.h"
-#include "folly/Portability.h"
-#include "folly/ScopeGuard.h"
+#include <folly/Conv.h>
+#include <folly/Portability.h>
+#include <folly/ScopeGuard.h>
 
 #include <cassert>
 #include <limits>
@@ -37,7 +37,7 @@ namespace folly {
  * until all data is written.  Note that *Full wrappers weaken the thread
  * semantics of underlying system calls.
  */
-int openNoInt(const char* name, int flags, mode_t mode=0644);
+int openNoInt(const char* name, int flags, mode_t mode = 0666);
 int closeNoInt(int fd);
 int dupNoInt(int fd);
 int dup2NoInt(int oldfd, int newfd);
@@ -123,7 +123,7 @@ bool readFile(const char* file_name, Container& out,
                 "readFile: only containers with byte-sized elements accepted");
   assert(file_name);
 
-  const auto fd = open(file_name, O_RDONLY);
+  const auto fd = openNoInt(file_name, O_RDONLY);
   if (fd == -1) return false;
 
   size_t soFar = 0; // amount of bytes successfully read
@@ -131,7 +131,7 @@ bool readFile(const char* file_name, Container& out,
     assert(out.size() >= soFar); // resize better doesn't throw
     out.resize(soFar);
     // Ignore errors when closing the file
-    close(fd);
+    closeNoInt(fd);
   };
 
   // Obtain file size: