src/share/vm/utilities/ostream.hpp

Print this page
rev 6853 : 8046070: Class Data Sharing clean up and refactoring
Summary: Cleaned up CDS to be more configurable, maintainable and extensible
Reviewed-by: dholmes, coleenp, acorn, mchung


 197  protected:
 198   FILE* _file;
 199   bool  _need_close;
 200  public:
 201   fileStream() { _file = NULL; _need_close = false; }
 202   fileStream(const char* file_name);
 203   fileStream(const char* file_name, const char* opentype);
 204   fileStream(FILE* file, bool need_close = false) { _file = file; _need_close = need_close; }
 205   ~fileStream();
 206   bool is_open() const { return _file != NULL; }
 207   void set_need_close(bool b) { _need_close = b;}
 208   virtual void write(const char* c, size_t len);
 209   size_t read(void *data, size_t size, size_t count) { return ::fread(data, size, count, _file); }
 210   char* readln(char *data, int count);
 211   int eof() { return feof(_file); }
 212   long fileSize();
 213   void rewind() { ::rewind(_file); }
 214   void flush();
 215 };
 216 


 217 // unlike fileStream, fdStream does unbuffered I/O by calling
 218 // open() and write() directly. It is async-safe, but output
 219 // from multiple thread may be mixed together. Used by fatal
 220 // error handler.
 221 class fdStream : public outputStream {
 222  protected:
 223   int  _fd;
 224   bool _need_close;
 225  public:
 226   fdStream(const char* file_name);
 227   fdStream(int fd = -1) { _fd = fd; _need_close = false; }
 228   ~fdStream();
 229   bool is_open() const { return _fd != -1; }
 230   void set_fd(int fd) { _fd = fd; _need_close = false; }
 231   int fd() const { return _fd; }
 232   virtual void write(const char* c, size_t len);
 233   void flush() {};
 234 };
 235 
 236 class gcLogFileStream : public fileStream {




 197  protected:
 198   FILE* _file;
 199   bool  _need_close;
 200  public:
 201   fileStream() { _file = NULL; _need_close = false; }
 202   fileStream(const char* file_name);
 203   fileStream(const char* file_name, const char* opentype);
 204   fileStream(FILE* file, bool need_close = false) { _file = file; _need_close = need_close; }
 205   ~fileStream();
 206   bool is_open() const { return _file != NULL; }
 207   void set_need_close(bool b) { _need_close = b;}
 208   virtual void write(const char* c, size_t len);
 209   size_t read(void *data, size_t size, size_t count) { return ::fread(data, size, count, _file); }
 210   char* readln(char *data, int count);
 211   int eof() { return feof(_file); }
 212   long fileSize();
 213   void rewind() { ::rewind(_file); }
 214   void flush();
 215 };
 216 
 217 CDS_ONLY(extern fileStream*   classlist_file;)
 218 
 219 // unlike fileStream, fdStream does unbuffered I/O by calling
 220 // open() and write() directly. It is async-safe, but output
 221 // from multiple thread may be mixed together. Used by fatal
 222 // error handler.
 223 class fdStream : public outputStream {
 224  protected:
 225   int  _fd;
 226   bool _need_close;
 227  public:
 228   fdStream(const char* file_name);
 229   fdStream(int fd = -1) { _fd = fd; _need_close = false; }
 230   ~fdStream();
 231   bool is_open() const { return _fd != -1; }
 232   void set_fd(int fd) { _fd = fd; _need_close = false; }
 233   int fd() const { return _fd; }
 234   virtual void write(const char* c, size_t len);
 235   void flush() {};
 236 };
 237 
 238 class gcLogFileStream : public fileStream {