message: Fix toco:toco_port compilation on Windows
diff: @@ -38,7 +38,8 @@ void CopyToBuffer(const Cord& src, char* dest) { src.CopyToArray(dest); }
  } // namespace port
  } // namespace toco
  -#if defined(PLATFORM_GOOGLE) && !defined(__APPLE__) && !defined(__ANDROID__)
  +#if defined(PLATFORM_GOOGLE) && !defined(__APPLE__) && \
  + !defined(__ANDROID__) && !defined(_WIN32)
  // Wrap Google file operations.
  @@ -115,9 +116,12 @@ string JoinPath(const string& a, const string& b) {
  } // namespace port
  } // namespace toco
  -#else // (__APPLE__ || __ANDROID__)
  +#else // !PLATFORM_GOOGLE || __APPLE__ || __ANDROID__ || _WIN32
  #include <fcntl.h>
  +#if defined(_WIN32)
  +#include <io.h> // for _close, _open, _read
  +#endif
  #include <sys/stat.h>
  #include <sys/types.h>
  #include <unistd.h>
  @@ -130,6 +134,19 @@ string JoinPath(const string& a, const string& b) {
  namespace toco {
  namespace port {
  +#if defined(_WIN32)
  +#define close _close
  +#define open _open
  +#define read _read
  +#define O_RDONLY _O_RDONLY
  +#define O_CREAT _O_CREAT
  +#define O_WRONLY _O_WRONLY
  +// Windows does not support the same set of file permissions as other platforms.
  +constexpr int kFileCreateMode = _S_IREAD | _S_IWRITE;
  +#else
  +constexpr int kFileCreateMode = 0664;
  +#endif // _WIN32
  +
  static bool port_initialized = false;
  void InitGoogle(const char* usage, int* argc, char*** argv, bool remove_flags) {
  @@ -209,7 +226,7 @@ tensorflow::Status GetContents(const string& path, string* output,
  tensorflow::Status SetContents(const string& filename, const string& contents,
  const file::Options& options) {
  - int fd = open(filename.c_str(), O_WRONLY | O_CREAT, 0664);
  + int fd = open(filename.c_str(), O_WRONLY | O_CREAT, kFileCreateMode);
  if (fd == -1) {
  return tensorflow::errors::Internal("can't open() for write");
  }
  @@ -243,4 +260,4 @@ string JoinPath(const string& base, const string& filename) {
  } // namespace port
  } // namespace toco
  -#endif // (__APPLE || __ANDROID__)
  +#endif // !PLATFORM_GOOGLE || __APPLE || __ANDROID__ || _WIN32
  