From: Steve Brokenshire Date: Mon, 22 Feb 2016 22:16:37 +0000 (+0000) Subject: Updated the ProcessConnectionDataFile subroutine. X-Git-Tag: release-0.02~346 X-Git-Url: http://Server1/repobrowser/?a=commitdiff_plain;h=15e1b2f8480eff7f827e5a81c7c700ed1a30429a;p=xestiacalendar%2F.git Updated the ProcessConnectionDataFile subroutine. --- diff --git a/source/tests/xestiacalendar_testcommon.cpp b/source/tests/xestiacalendar_testcommon.cpp index 7e96498..99cf8fa 100644 --- a/source/tests/xestiacalendar_testcommon.cpp +++ b/source/tests/xestiacalendar_testcommon.cpp @@ -1,9 +1,47 @@ +#include + #include "xestiacalendar_testcommon.h" +#include "../common/file.h" -CalDAVConnectionData ProcessConnectionDataFile(string DataFilename){ +ProcessConnectionDataFileResult ProcessConnectionDataFile(string DataFilename, + CalDAVConnectionData *ConnData){ + + ProcessConnectionDataFileResult ProcessResult = PROCESSCONNECTIONDATAFILE_UNITTESTFAIL; + + // Check if the file exists and return + // PROCESSCONNECTIONDATAFILE_MISSING if not. + + if (!FileExists(DataFilename)){ + return PROCESSCONNECTIONDATAFILE_MISSING; + } + + ifstream FileStream; + string ReceivedStringData = ""; + + FileStream.open(DataFilename, ifstream::in); + + if (FileStream.rdstate() & ifstream::failbit){ + return PROCESSCONNECTIONDATAFILE_CANNOTOPEN; + } - CalDAVConnectionData ConnData; + if (FileStream.rdstate() & ifstream::badbit){ + return PROCESSCONNECTIONDATAFILE_CANNOTOPEN; + } + + // Process the file. + + char *BufferRead = new char[256]; + + while (!FileStream.eof()){ + + FileStream.getline(BufferRead, 256); + ReceivedStringData.append(BufferRead); + ReceivedStringData.append("\n"); + + } - return ConnData; + delete[] BufferRead; + return ProcessResult; + } \ No newline at end of file diff --git a/source/tests/xestiacalendar_testcommon.h b/source/tests/xestiacalendar_testcommon.h index 1e23eb4..e925dbb 100644 --- a/source/tests/xestiacalendar_testcommon.h +++ b/source/tests/xestiacalendar_testcommon.h @@ -6,6 +6,14 @@ using namespace std; -CalDAVConnectionData ProcessConnectionDataFile(string DataFilename); +enum ProcessConnectionDataFileResult{ + PROCESSCONNECTIONDATAFILE_UNITTESTFAIL = -1, + PROCESSCONNECTIONDATAFILE_OK, + PROCESSCONNECTIONDATAFILE_MISSING, + PROCESSCONNECTIONDATAFILE_CANNOTOPEN +}; + +ProcessConnectionDataFileResult ProcessConnectionDataFile(string DataFilename, + CalDAVConnectionData *ConnData); #endif \ No newline at end of file