#include #include #include #include void ExportVCard4(bool DirMode, wxString OutputLocation, wxArrayString *FileList, int *ExportCount){ if (DirMode == TRUE){ // Output each contact into the directory. // Simply just copy the files unchanged. wxString Filename; wxString FinalFilename; for (int i = 0; i < FileList->GetCount(); i++){ // Get the final part of the path (filename). #if defined(__HAIKU__) #elif defined(__WIN32__) wxStringTokenizer FileToken(FileList->Item(i), wxT("//")); while (FileToken.HasMoreTokens()){ Filename = FileToken.GetNextToken(); } // Copy the file to the requested directory. FinalFilename.Append(OutputLocation); FinalFilename.Append(wxT("/")); FinalFilename.Append(Filename); #else wxStringTokenizer FileToken(FileList->Item(i), wxT("//")); while(FileToken.HasMoreTokens()){ Filename = FileToken.GetNextToken(); } // Copy the file to the requested directory. FinalFilename.Append(OutputLocation); FinalFilename.Append(wxT("/")); FinalFilename.Append(Filename); #endif bool CopyResult = wxCopyFile(FileList->Item(i), FinalFilename); (*ExportCount)++; Filename.Clear(); FinalFilename.Clear(); } } else { // Output all contacts into one file. wxFFile OutputFile; wxFFile InputFile; // Open the output file. #if wxABI_VERSION < 20900 OutputFile.Open(OutputLocation.c_str(), wxT("w")); #else OutputFile.Open(OutputLocation, wxT("w")); #endif wxString InputFileData; for (int i = 0; i < FileList->GetCount(); i++){ // Open up the input file. InputFile.Open(FileList->Item(i), wxT("r")); InputFile.ReadAll(&InputFileData, wxConvAuto()); OutputFile.Write(InputFileData, wxConvAuto()); InputFile.Close(); InputFileData.Clear(); (*ExportCount)++; } OutputFile.Close(); } }