** 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.20 2000/12/16 02:44:26 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
******************************************************************************/
#include "array2dfile.h"
-#include <ctime>
-#ifndef WIN32
-#include <sstream>
+#include <ctime>\r
+#ifdef MSVC\r
+typedef long off_t;\r
#endif
using namespace std;
const string&
Array2dFileLabel::getDateString (void) const
{
- ostringstream oss;
- oss << static_cast<int>(m_month + 1) <<"/"<< static_cast<int>(m_day) <<"/"<< static_cast<int>(m_year + 1900) << " " << static_cast<int>(m_hour) <<":"<< static_cast<int>(m_minute) <<":"<< static_cast<int>(m_second);
- m_strDate = oss.str();
+ char szDate [128];\r
+ snprintf (szDate, sizeof(szDate), "%2d/%02d/%4d %02d:%02d:%02d",\r
+ m_month + 1, m_day, m_year + 1900, m_hour, m_minute, m_second);
+ m_strDate = szDate;
return m_strDate;
}
}
void
-Array2dFileLabel::print (ostream& os) const
+Array2dFileLabel::print (std::ostream& os) const
{
if (m_labelType == L_HISTORY) {
os << "History: " << endl;
{
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;
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);
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;
}
void
-Array2dFile::labelsCopy (Array2dFile& copyFile, const char* const idStr)
+Array2dFile::labelsCopy (Array2dFile& copyFile, const char* const pszId)
{
- string id = idStr;
+ string id;
+ if (pszId)
+ id = pszId;
for (unsigned int i = 0; i < copyFile.getNumLabels(); i++) {
Array2dFileLabel l (copyFile.labelGet (i));
string lstr = l.getLabelString();
- lstr = idStr + lstr;
+ lstr = id + lstr;
l.setLabelString (lstr);
labelAdd (l);
}