source: trunk/tmdmcreator/src/tmdmcopier.cpp @ 16

Revision 16, 1.9 KB checked in by lucsch, 12 years ago (diff)

Copying Base and User SQL files into output file is now working

Line 
1/***************************************************************************
2 tmdmcopier.cpp
3 -------------------
4 copyright            : (C) 2013 CREALP Lucien Schreiber
5 email                : lucien.schreiber at crealp dot vs dot ch
6 ***************************************************************************/
7
8/***************************************************************************
9 *                                                                         *
10 *   This program is free software; you can redistribute it and/or modify  *
11 *   it under the terms of the GNU General Public License as published by  *
12 *   the Free Software Foundation; either version 2 of the License, or     *
13 *   (at your option) any later version.                                   *
14 *                                                                         *
15 ***************************************************************************/
16
17#include "tmdmcopier.h"
18
19TmDmCopier::TmDmCopier(const wxFileName & destfile) {
20    m_File = new wxFFile();
21    bool bOpen = m_File->Open(destfile.GetFullPath(), "a");
22    wxASSERT(bOpen == true);
23}
24
25
26
27TmDmCopier::~TmDmCopier() {
28    wxDELETE(m_File);
29}
30
31
32
33bool TmDmCopier::CopyFrom(const wxFileName & filename) {
34    wxFFile mySrcFile;
35    if (mySrcFile.Open(filename.GetFullPath()) == false) {
36        m_Errors.Add(wxString::Format(_("Unable to open: %s"), filename.GetFullPath()));
37        return false;
38    }
39   
40    wxString mySrcTxt;
41    if(mySrcFile.ReadAll(&mySrcTxt)==false){
42        m_Errors.Add(wxString::Format(_("Reading from: %s failed!"), filename.GetFullPath()));
43        return false;
44    }
45    return CopyFrom(mySrcTxt);
46}
47
48
49
50bool TmDmCopier::CopyFrom(const wxString & text) {
51    if (m_File->Write(text) == false) {
52        m_Errors.Add(wxString::Format(_("Writing to: %s failed!"), m_File->GetName()));
53        return false;
54    }
55   
56    return true;
57}
58
59
60
61wxArrayString TmDmCopier::GetErrors(){
62    return m_Errors;
63}
Note: See TracBrowser for help on using the repository browser.