Mercurial > hg > graal-compiler
diff src/share/vm/utilities/ostream.cpp @ 2199:d8a72fbc4be7
7003401: Implement VM error-reporting functionality on erroneous termination
Summary: Add support for distribution-specific error reporting
Reviewed-by: coleenp, phh, jcoomes, ohair
author | kamg |
---|---|
date | Tue, 08 Feb 2011 17:20:45 -0500 |
parents | 828eafbd85cc |
children | 5841dc1964f0 |
line wrap: on
line diff
--- a/src/share/vm/utilities/ostream.cpp Thu Feb 03 20:30:19 2011 -0800 +++ b/src/share/vm/utilities/ostream.cpp Tue Feb 08 17:20:45 2011 -0500 @@ -314,6 +314,11 @@ _need_close = true; } +fileStream::fileStream(const char* file_name, const char* opentype) { + _file = fopen(file_name, opentype); + _need_close = true; +} + void fileStream::write(const char* s, size_t len) { if (_file != NULL) { // Make an unused local variable to avoid warning from gcc 4.x compiler. @@ -322,6 +327,25 @@ update_position(s, len); } +long fileStream::fileSize() { + long size = -1; + if (_file != NULL) { + long pos = ::ftell(_file); + if (::fseek(_file, 0, SEEK_END) == 0) { + size = ::ftell(_file); + } + ::fseek(_file, pos, SEEK_SET); + } + return size; +} + +char* fileStream::readln(char *data, int count ) { + char * ret = ::fgets(data, count, _file); + //Get rid of annoying \n char + data[::strlen(data)-1] = '\0'; + return ret; +} + fileStream::~fileStream() { if (_file != NULL) { if (_need_close) fclose(_file);