X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;ds=sidebyside;f=libctsim%2Farray2dfile.cpp;h=36adfbaa0017fb1447322e1a32bcbfbf2c773ce1;hb=849eba23462dc48c9284b01ba738321ec25689b4;hp=121f3c862a3bcad3b1940c07ef7303ad168591b4;hpb=2debde82a721c0cf5bdf6642ace3290f83bb21a4;p=ctsim.git diff --git a/libctsim/array2dfile.cpp b/libctsim/array2dfile.cpp index 121f3c8..36adfba 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.12 2000/12/04 03:42:00 kevin Exp $ +** $Id: array2dfile.cpp,v 1.17 2000/12/14 20:59:30 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 @@ -26,9 +26,9 @@ ******************************************************************************/ #include "array2dfile.h" -#include -#ifndef WIN32 -#include +#include +#ifdef MSVC +typedef long off_t; #endif using namespace std; @@ -109,9 +109,10 @@ Array2dFileLabel::getDateTime (int& year, int& month, int& day, int& hour, int& const string& Array2dFileLabel::getDateString (void) const { - ostringstream oss; - oss << static_cast(m_month + 1) <<"/"<< static_cast(m_day) <<"/"<< static_cast(m_year + 1900) << " " << static_cast(m_hour) <<":"<< static_cast(m_minute) <<":"<< static_cast(m_second); - m_strDate = oss.str(); + char szDate [128]; + snprintf (szDate, sizeof(szDate), "%2d/%02d/%4d %02d:%02d:%02d", + m_month + 1, m_day, m_year + 1900, m_hour, m_minute, m_second); + m_strDate = szDate; return m_strDate; } @@ -279,7 +280,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 +394,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); @@ -477,13 +482,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; @@ -548,9 +555,11 @@ Array2dFile::labelAdd (const Array2dFileLabel& label) } void -Array2dFile::labelsCopy (Array2dFile& copyFile, const char* const idStr) +Array2dFile::labelsCopy (Array2dFile& copyFile, const char* const pszId) { - string id = idStr; + string id; + if (idStr) + id = pszId; for (unsigned int i = 0; i < copyFile.getNumLabels(); i++) { Array2dFileLabel l (copyFile.labelGet (i)); string lstr = l.getLabelString();