X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fconvert.cpp;h=69926de76dddbafa9a157f36b9f943f456ed6d1c;hb=2934c09b149efeb7f0dd7b5f2e8c12a578b05da4;hp=d8578d7263ed259badab1b787e316600a0c60a1b;hpb=e2afc613b2d4292d461af99ee3443b23a5b1d55a;p=xestiaab%2F.git diff --git a/source/convert.cpp b/source/convert.cpp index d8578d7..69926de 100644 --- a/source/convert.cpp +++ b/source/convert.cpp @@ -26,7 +26,7 @@ ConvertResult ConvertContact(wxString InputFormat, wxString OutputFormat, wxT("vCard4") }; - bool ValidImport = false; + bool ValidInput = false; bool ValidOutput = false; // Check that the input format is valid. @@ -34,26 +34,62 @@ ConvertResult ConvertContact(wxString InputFormat, wxString OutputFormat, for (long l = 0; l < ValidFormats.size(); l++){ if (InputFormat == ValidFormats[l]){ - ValidImport = true; + ValidInput = true; break; } } - if (ValidImport == false){ + if (ValidInput == false){ - return CONVERTRESULT_INVALIDIMPORTFORMAT; + return CONVERTRESULT_INVALIDINPUTFORMAT; } + // Check that the output format is valid. + + for (long l = 0; l < ValidFormats.size(); l++){ + + if (OutputFormat == ValidFormats[l]){ + ValidOutput = true; + break; + } + + } + + if (ValidOutput == false){ + + return CONVERTRESULT_INVALIDOUTPUTFORMAT; + + } + + // Check that the input and output formats + // are not the same. + if (InputFormat == OutputFormat){ return CONVERTRESULT_FORMATSSAME; } - // Check that the output format is valid. - + // Check that the input file given exists. + + if (!wxFileExists(InputFilename)){ + + return CONVERTRESULT_INPUTFILEMISSING; + + } + + wxFile InputFile; + + if (!InputFile.Open(InputFilename, wxFile::read, wxS_DEFAULT)){ + + int InputFileErrNo = InputFile.GetLastError(); + + return CONVERTRESULT_INPUTFILEERROR; + + } + return CONVERTRESULT_OK; } \ No newline at end of file