Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Initial import of code already done for Xestia Address Book
[xestiaab/.git] / source / export / export-vcard4.cpp
1 #include <wx/ffile.h>
2 #include <wx/arrstr.h>
3 #include <wx/filefn.h>
4 #include <wx/tokenzr.h>
6 void ExportVCard4(bool DirMode, wxString OutputLocation, wxArrayString *FileList, int *ExportCount){
8         if (DirMode == TRUE){
9         
10                 // Output each contact into the directory.
11         
12                 // Simply just copy the files unchanged.
13                 
14                 wxString Filename;
15                 wxString FinalFilename;
16                 
17                 for (int i = 0; i < FileList->GetCount(); i++){
18                 
19                         // Get the final part of the path (filename).
20                         
21 #if defined(__HAIKU__)
22     
24 #elif defined(__WIN32__)
26                         wxStringTokenizer FileToken(FileList->Item(i), wxT("//"));
28                         while (FileToken.HasMoreTokens()){
29                                 Filename = FileToken.GetNextToken();
30                         }
32                         // Copy the file to the requested directory.
34                         FinalFilename.Append(OutputLocation);
35                         FinalFilename.Append(wxT("/"));
36                         FinalFilename.Append(Filename);
38 #else
39                         
40                         wxStringTokenizer FileToken(FileList->Item(i), wxT("//"));
42                         while(FileToken.HasMoreTokens()){
43                                 Filename = FileToken.GetNextToken();
44                         }
45                 
46                         // Copy the file to the requested directory.
47                 
48                         FinalFilename.Append(OutputLocation);
49                         FinalFilename.Append(wxT("/"));
50                         FinalFilename.Append(Filename);
52 #endif
53                 
54                         bool CopyResult = wxCopyFile(FileList->Item(i), FinalFilename);
55                         
56                         (*ExportCount)++;
57                         
58                         Filename.Clear();
59                         FinalFilename.Clear();
60                 
61                 }
62         
63         } else {
64         
65                 // Output all contacts into one file.
66                 
67                 wxFFile OutputFile;
68                 wxFFile InputFile;
69                 
70                 // Open the output file.
71                 
72 #if wxABI_VERSION < 20900
73                 OutputFile.Open(OutputLocation.c_str(), wxT("w"));
74 #else
75                 OutputFile.Open(OutputLocation, wxT("w"));
76 #endif
77                 
78                 wxString InputFileData;
79                 
80                 for (int i = 0; i < FileList->GetCount(); i++){
81                 
82                         // Open up the input file.
83                 
84                         InputFile.Open(FileList->Item(i), wxT("r"));
85                         
86                         InputFile.ReadAll(&InputFileData, wxConvAuto());
88                         OutputFile.Write(InputFileData, wxConvAuto());
89                         
90                         InputFile.Close();
91                         InputFileData.Clear();
92                         
93                         (*ExportCount)++;
94                 
95                 }
96         
97                 OutputFile.Close();
98         
99         }
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