Fix open_buffered_file

This commit is contained in:
vitaut 2015-07-08 07:48:54 -07:00
parent b6c1c9233a
commit f3bef7ac92
2 changed files with 3 additions and 3 deletions

View File

@ -50,12 +50,12 @@ std::string get_system_error(int error_code) {
#endif #endif
} }
const char *FILE_CONTENT = "Don't panic!"; const char *const FILE_CONTENT = "Don't panic!";
fmt::BufferedFile open_buffered_file(FILE **fp) { fmt::BufferedFile open_buffered_file(FILE **fp) {
fmt::File read_end, write_end; fmt::File read_end, write_end;
fmt::File::pipe(read_end, write_end); fmt::File::pipe(read_end, write_end);
write_end.write(FILE_CONTENT, sizeof(FILE_CONTENT) - 1); write_end.write(FILE_CONTENT, std::strlen(FILE_CONTENT));
write_end.close(); write_end.close();
fmt::BufferedFile f = read_end.fdopen("r"); fmt::BufferedFile f = read_end.fdopen("r");
if (fp) if (fp)

View File

@ -52,7 +52,7 @@ void increment(char *s);
std::string get_system_error(int error_code); std::string get_system_error(int error_code);
extern const char *FILE_CONTENT; extern const char *const FILE_CONTENT;
// Opens a buffered file for reading. // Opens a buffered file for reading.
fmt::BufferedFile open_buffered_file(FILE **fp = 0); fmt::BufferedFile open_buffered_file(FILE **fp = 0);