X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=libctsim%2Farray2dfile.cpp;h=b16c7d3b7810db59fd734e8cca62c24fe73e1201;hp=f3e6dc9262007fe2e966f7ca4ed1b5d197511902;hb=ee0105d74fec9d6bfd236e22e9e1d315e46c568e;hpb=b3b4d9344312f9812e4782c215db0133913802bc diff --git a/libctsim/array2dfile.cpp b/libctsim/array2dfile.cpp index f3e6dc9..b16c7d3 100644 --- a/libctsim/array2dfile.cpp +++ b/libctsim/array2dfile.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: array2dfile.cpp,v 1.11 2000/12/04 03:12:18 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 -#ifndef WIN32 #include -#endif + using namespace std; @@ -62,7 +61,7 @@ Array2dFileLabel::Array2dFileLabel() init(); } -Array2dFileLabel::Array2dFileLabel(const char* const str, double ctime = 0.) +Array2dFileLabel::Array2dFileLabel(const char* const str, double ctime) : m_strLabel (str) { init(); @@ -71,7 +70,7 @@ Array2dFileLabel::Array2dFileLabel(const char* const str, double ctime = 0.) m_calcTime = ctime; } -Array2dFileLabel::Array2dFileLabel(const int type, const char* const str, double ctime = 0.) +Array2dFileLabel::Array2dFileLabel(const int type, const char* const str, double ctime) : m_strLabel (str) { init(); @@ -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 + frnetorderstream fs (m_filename.c_str(), ios::out | ios::in | ios::binary); +#else + frnetorderstream fs (m_filename.c_str(), ios::out | ios::in | ios::binary | ios::nocreate); +#endif 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(fs.tellp()); fs.seekp (0); fs.writeInt16 (m_headersize); @@ -415,11 +418,11 @@ Array2dFile::arrayDataWrite (frnetorderstream& fs) if (NativeBigEndian()) { for (unsigned int iy = 0; iy < m_ny; iy++) { ConvertReverseNetworkOrder (ptrColumn, m_pixelSize); - fs.write (ptrColumn, m_pixelSize); + fs.write (reinterpret_cast(ptrColumn), m_pixelSize); ptrColumn += m_pixelSize; } } else - fs.write (ptrColumn, columnSize); + fs.write (reinterpret_cast(ptrColumn), columnSize); } return true; @@ -443,12 +446,12 @@ Array2dFile::arrayDataRead (frnetorderstream& fs) unsigned char* ptrColumn = m_arrayData[ix]; if (NativeBigEndian()) { for (unsigned int iy = 0; iy < m_ny; iy++) { - fs.read (ptrColumn, m_pixelSize); + fs.read (reinterpret_cast(ptrColumn), m_pixelSize); ConvertReverseNetworkOrder (ptrColumn, m_pixelSize); ptrColumn += m_pixelSize; } } else - fs.read (ptrColumn, columnSize); + fs.read (reinterpret_cast(ptrColumn), columnSize); } return true; @@ -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; + pLabel->setDateTime (year, month, day, hour, minute, second); - m_labels.push_back (pLabel); + m_labels.push_back (pLabel); } return true; @@ -524,14 +529,14 @@ Array2dFile::labelsWrite (frnetorderstream& fs) } void -Array2dFile::labelAdd (const char* const lstr, double calc_time=0.) +Array2dFile::labelAdd (const char* const lstr, double calc_time) { labelAdd (Array2dFileLabel::L_HISTORY, lstr, calc_time); } void -Array2dFile::labelAdd (int type, const char* const lstr, double calc_time=0.) +Array2dFile::labelAdd (int type, const char* const lstr, double calc_time) { Array2dFileLabel label (type, lstr, calc_time);