hotspot/src/share/vm/utilities/ostream.cpp
changeset 8114 340b5b8b544b
parent 7405 e6fc8d3926f8
child 8333 11a7f6fc6419
--- a/hotspot/src/share/vm/utilities/ostream.cpp	Thu Feb 03 20:30:19 2011 -0800
+++ b/hotspot/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);