Skip to content

Commit

Permalink
use correct arguments on non-windows
Browse files Browse the repository at this point in the history
  • Loading branch information
madeso committed Nov 26, 2015
1 parent 2a819c9 commit bc16ba5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions code-stat-everything.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
-----------------------------------------------------------------------------------
Language files blank comment code
-----------------------------------------------------------------------------------
C++ 66 3425 961 15242
C++ 66 3427 961 15233
C/C++ Header 72 948 390 2954
Protocol Buffers 1 93 14 451
CMake 2 46 16 230
Windows Resource File 1 4 0 29
XML 1 0 0 8
-----------------------------------------------------------------------------------
SUM: 143 4516 1381 18914
SUM: 143 4518 1381 18905
-----------------------------------------------------------------------------------
16 changes: 14 additions & 2 deletions external/pbjson/src/pbjson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,13 @@ namespace pbjson

bool json2file(const rapidjson::Value* json, const std::string& str, bool pretty)
{
FILE* fp = fopen(str.c_str(), "wb"); // non-Windows use "w"
FILE* fp = fopen(str.c_str(),
#ifdef WIN32
"wb"
#else
"w"
#endif
);
if (fp == NULL) return false;
char writeBuffer[65536];
rapidjson::FileWriteStream os(fp, writeBuffer, sizeof(writeBuffer));
Expand Down Expand Up @@ -583,7 +589,13 @@ namespace pbjson
int json2pb_file(const std::string& path, google::protobuf::Message* msg, std::string& err)
{
rapidjson::Document d;
FILE* fp = fopen(path.c_str(), "rb"); // non-Windows use "r"
FILE* fp = fopen(path.c_str(),
#ifdef WIN32
"rb"
#else
"r"
#endif
);
if (fp == NULL) {
err += "Unable to open file";
return ERR_INVALID_FILE;
Expand Down

0 comments on commit bc16ba5

Please sign in to comment.