+#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
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