Mercurial > hg > truffle
comparison 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 |
comparison
equal
deleted
inserted
replaced
2197:5e139f767ddb | 2199:d8a72fbc4be7 |
---|---|
312 fileStream::fileStream(const char* file_name) { | 312 fileStream::fileStream(const char* file_name) { |
313 _file = fopen(file_name, "w"); | 313 _file = fopen(file_name, "w"); |
314 _need_close = true; | 314 _need_close = true; |
315 } | 315 } |
316 | 316 |
317 fileStream::fileStream(const char* file_name, const char* opentype) { | |
318 _file = fopen(file_name, opentype); | |
319 _need_close = true; | |
320 } | |
321 | |
317 void fileStream::write(const char* s, size_t len) { | 322 void fileStream::write(const char* s, size_t len) { |
318 if (_file != NULL) { | 323 if (_file != NULL) { |
319 // Make an unused local variable to avoid warning from gcc 4.x compiler. | 324 // Make an unused local variable to avoid warning from gcc 4.x compiler. |
320 size_t count = fwrite(s, 1, len, _file); | 325 size_t count = fwrite(s, 1, len, _file); |
321 } | 326 } |
322 update_position(s, len); | 327 update_position(s, len); |
328 } | |
329 | |
330 long fileStream::fileSize() { | |
331 long size = -1; | |
332 if (_file != NULL) { | |
333 long pos = ::ftell(_file); | |
334 if (::fseek(_file, 0, SEEK_END) == 0) { | |
335 size = ::ftell(_file); | |
336 } | |
337 ::fseek(_file, pos, SEEK_SET); | |
338 } | |
339 return size; | |
340 } | |
341 | |
342 char* fileStream::readln(char *data, int count ) { | |
343 char * ret = ::fgets(data, count, _file); | |
344 //Get rid of annoying \n char | |
345 data[::strlen(data)-1] = '\0'; | |
346 return ret; | |
323 } | 347 } |
324 | 348 |
325 fileStream::~fileStream() { | 349 fileStream::~fileStream() { |
326 if (_file != NULL) { | 350 if (_file != NULL) { |
327 if (_need_close) fclose(_file); | 351 if (_need_close) fclose(_file); |