Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Updated the ProcessConnectionDataFile subroutine.
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Mon, 22 Feb 2016 22:16:37 +0000 (22:16 +0000)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Mon, 22 Feb 2016 22:16:37 +0000 (22:16 +0000)
source/tests/xestiacalendar_testcommon.cpp
source/tests/xestiacalendar_testcommon.h

index 7e96498..99cf8fa 100644 (file)
@@ -1,9 +1,47 @@
+#include <fstream>
+
 #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
index 1e23eb4..e925dbb 100644 (file)
@@ -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
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy