Fix missing mode_t on Windows.
Change-Id: Iba76c09bdb75cdf3eb11274ccfe31412613bba97
diff --git a/include/perfetto/base/scoped_file.h b/include/perfetto/base/scoped_file.h
index 7e380f0..59ca75f 100644
--- a/include/perfetto/base/scoped_file.h
+++ b/include/perfetto/base/scoped_file.h
@@ -24,6 +24,7 @@
#if PERFETTO_BUILDFLAG(PERFETTO_OS_WIN)
#include <corecrt_io.h>
+typedef int mode_t;
#else
#include <dirent.h>
#include <unistd.h>
@@ -36,6 +37,8 @@
namespace perfetto {
namespace base {
+constexpr mode_t kInvalidMode = static_cast<mode_t>(-1);
+
// RAII classes for auto-releasing fds and dirs.
template <typename T,
int (*CloseFunction)(T),
@@ -81,8 +84,8 @@
using ScopedFile = ScopedResource<int, close, -1>;
inline static ScopedFile OpenFile(const std::string& path,
int flags,
- mode_t mode = 0) {
- PERFETTO_DCHECK((flags & O_CREAT) == 0 || mode != 0);
+ mode_t mode = kInvalidMode) {
+ PERFETTO_DCHECK((flags & O_CREAT) == 0 || mode != kInvalidMode);
#if PERFETTO_BUILDFLAG(PERFETTO_OS_WIN)
ScopedFile fd(open(path.c_str(), flags, mode));
#else