4 #include <wx/tokenzr.h>
6 #include "../vcard/vcard.h"
7 #include "../vcard/vcard34conv.h"
9 void ExportVCard3(bool DirMode, wxString OutputLocation, wxArrayString *FileList, int *ExportCount){
13 // Output each contact into the directory.
15 // Load the contact file and covert it to vCard 3.0.
18 wxString FinalFilename;
21 for (int i = 0; i < FileList->GetCount(); i++){
23 // Get the final part of the path (filename).
25 vCard34Conv vCardConvObj;
26 vCardConvObj.ConvertToV3(FileList->Item(i), &ContactData);
28 #if defined(__HAIKU__)
31 #elif defined(__WIN32__)
33 wxStringTokenizer FileToken(FileList->Item(i), wxT("\\"));
35 while (FileToken.HasMoreTokens()){
36 Filename = FileToken.GetNextToken();
39 FinalFilename.Append(OutputLocation);
40 FinalFilename.Append(wxT("\\"));
41 FinalFilename.Append(Filename);
45 wxStringTokenizer FileToken(FileList->Item(i), wxT("//"));
47 while(FileToken.HasMoreTokens()){
48 Filename = FileToken.GetNextToken();
51 FinalFilename.Append(OutputLocation);
52 FinalFilename.Append(wxT("/"));
53 FinalFilename.Append(Filename);
57 // Write the converted card to the file.
61 #if wxABI_VERSION < 20900
62 OutputFile.Open(FinalFilename, wxT("w"));
64 OutputFile.Open(FinalFilename, wxT("w"));
67 OutputFile.Write(ContactData, wxConvAuto());
74 FinalFilename.Clear();
81 // Output all contacts into one file.
85 // Open the output file.
87 #if wxABI_VERSION < 20900
88 OutputFile.Open(OutputLocation.c_str(), wxT("w"));
90 OutputFile.Open(OutputLocation, wxT("w"));
93 wxString InputFileData;
95 for (int i = 0; i < FileList->GetCount(); i++){
97 // Open up the input file.
99 vCard34Conv vCardConvObj;
100 vCardConvObj.ConvertToV3(FileList->Item(i), &InputFileData);
102 OutputFile.Write(InputFileData, wxConvAuto());
104 InputFileData.Clear();