Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Unit Tests: Updated copyright year on modified files
[xestiaab/.git] / source / export / export-vcard4.cpp
1 // export-vcard4.cpp - Export vCard4 subroutines.
2 //
3 // (c) 2012-2015 Xestia Software Development.
4 //
5 // This file is part of Xestia Address Book.
6 //
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
10 //
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
19 #include <wx/ffile.h>
20 #include <wx/arrstr.h>
21 #include <wx/filefn.h>
22 #include <wx/tokenzr.h>
24 void ExportVCard4(bool DirMode, wxString OutputLocation, wxArrayString *FileList, int *ExportCount){
26         // Export a vCard 4.0 contact file.
27         
28         if (DirMode == TRUE){
29         
30                 // Output each contact into the directory.
31         
32                 // Simply just copy the files unchanged.
33                 
34                 wxString Filename;
35                 wxString FinalFilename;
36                 
37                 for (int i = 0; i < FileList->GetCount(); i++){
38                 
39                         // Get the final part of the path (filename).
40                         
41 #if defined(__HAIKU__)
42     
44 #elif defined(__WIN32__)
46                         wxStringTokenizer FileToken(FileList->Item(i), wxT("//"));
48                         while (FileToken.HasMoreTokens()){
49                                 Filename = FileToken.GetNextToken();
50                         }
52                         // Copy the file to the requested directory.
54                         FinalFilename.Append(OutputLocation);
55                         FinalFilename.Append(wxT("/"));
56                         FinalFilename.Append(Filename);
58 #else
59                         
60                         wxStringTokenizer FileToken(FileList->Item(i), wxT("//"));
62                         while(FileToken.HasMoreTokens()){
63                                 Filename = FileToken.GetNextToken();
64                         }
65                 
66                         // Copy the file to the requested directory.
67                 
68                         FinalFilename.Append(OutputLocation);
69                         FinalFilename.Append(wxT("/"));
70                         FinalFilename.Append(Filename);
72 #endif
73                         
74                         (*ExportCount)++;
75                         
76                         Filename.Clear();
77                         FinalFilename.Clear();
78                 
79                 }
80         
81         } else {
82         
83                 // Output all contacts into one file.
84                 
85                 wxFFile OutputFile;
86                 wxFFile InputFile;
87                 
88                 // Open the output file.
89                 
90 #if wxABI_VERSION < 20900
91                 OutputFile.Open(OutputLocation.c_str(), wxT("w"));
92 #else
93                 OutputFile.Open(OutputLocation, wxT("w"));
94 #endif
95                 
96                 wxString InputFileData;
97                 
98                 for (int i = 0; i < FileList->GetCount(); i++){
99                 
100                         // Open up the input file.
101                 
102                         InputFile.Open(FileList->Item(i), wxT("r"));
103                         
104                         InputFile.ReadAll(&InputFileData, wxConvAuto());
106                         OutputFile.Write(InputFileData, wxConvAuto());
107                         
108                         InputFile.Close();
109                         InputFileData.Clear();
110                         
111                         (*ExportCount)++;
112                 
113                 }
114         
115                 OutputFile.Close();
116         
117         }
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