r246: More modifications for MSVC
[ctsim.git] / libctsim / array2dfile.cpp
index 121f3c862a3bcad3b1940c07ef7303ad168591b4..b16c7d3b7810db59fd734e8cca62c24fe73e1201 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: array2dfile.cpp,v 1.12 2000/12/04 03:42:00 kevin Exp $
+**  $Id: array2dfile.cpp,v 1.15 2000/12/06 01:46:43 kevin Exp $
 **
 **  This program is free software; you can redistribute it and/or modify
 **  it under the terms of the GNU General Public License (version 2) as
@@ -27,9 +27,8 @@
 
 #include "array2dfile.h"
 #include <ctime>
-#ifndef WIN32
 #include <sstream>
-#endif
+
 
 using namespace std;
 
@@ -279,7 +278,11 @@ Array2dFile::fileRead (const char* const filename)
 {
     m_filename = filename;
 
-    frnetorderstream fs (m_filename.c_str(), ios::out | ios::in | ios::binary | ios::nocreate);
+#ifdef MSVC\r
+    frnetorderstream fs (m_filename.c_str(), ios::out | ios::in | ios::binary);\r
+#else\r
+    frnetorderstream fs (m_filename.c_str(), ios::out | ios::in | ios::binary | ios::nocreate);\r
+#endif\r
     if (fs.fail()) {
       sys_error (ERR_WARNING, "Unable to open file %s [fileRead]", m_filename.c_str());
       return false;
@@ -389,7 +392,7 @@ Array2dFile::headerWrite (frnetorderstream& fs)
   fs.writeFloat64 (m_offsetPV);
   fs.writeFloat64 (m_scalePV);
 
-  m_headersize = fs.tellp();
+  m_headersize = static_cast<kuint16>(fs.tellp());
   fs.seekp (0);
   fs.writeInt16 (m_headersize);
   
@@ -477,13 +480,15 @@ Array2dFile::labelsRead (frnetorderstream& fs)
        
        kuint16 strLength;
        fs.readInt16 (strLength);
-       char labelStr [strLength+1];
-       fs.read (labelStr, strLength);
-       labelStr[strLength] = 0;
+       char* pszLabelStr = new char [strLength+1];
+       fs.read (pszLabelStr, strLength);
+       pszLabelStr[strLength] = 0;
 
-       Array2dFileLabel* pLabel = new Array2dFileLabel(labelType, labelStr, calcTime);
+       Array2dFileLabel* pLabel = new Array2dFileLabel (labelType, pszLabelStr, calcTime);
+       delete pszLabelStr;\r
+\r
        pLabel->setDateTime (year, month, day, hour, minute, second);
-       m_labels.push_back (pLabel);
+       m_labels.push_back (pLabel);\r
     }
 
     return true;