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

Revision 18, 2.0 KB checked in by lucsch, 12 years ago (diff)
  • Preliminary code for processing user_content.txt. Processing thematic_layers is now working
  • Corrected base_structure and user_structure.sql
RevLine 
[15]1/***************************************************************************
2 tmdmcopier.cpp
3 -------------------
[16]4 copyright            : (C) 2013 CREALP Lucien Schreiber
[15]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) {
[16]20    m_File = new wxFFile();
21    bool bOpen = m_File->Open(destfile.GetFullPath(), "a");
22    wxASSERT(bOpen == true);
[15]23}
24
[16]25
26
[15]27TmDmCopier::~TmDmCopier() {
[18]28    m_File->Flush();
[16]29    wxDELETE(m_File);
[15]30}
31
32
[16]33
[15]34bool TmDmCopier::CopyFrom(const wxFileName & filename) {
[16]35    wxFFile mySrcFile;
36    if (mySrcFile.Open(filename.GetFullPath()) == false) {
37        m_Errors.Add(wxString::Format(_("Unable to open: %s"), filename.GetFullPath()));
38        return false;
39    }
40   
41    wxString mySrcTxt;
42    if(mySrcFile.ReadAll(&mySrcTxt)==false){
43        m_Errors.Add(wxString::Format(_("Reading from: %s failed!"), filename.GetFullPath()));
44        return false;
45    }
46    return CopyFrom(mySrcTxt);
[15]47}
48
[16]49
50
[15]51bool TmDmCopier::CopyFrom(const wxString & text) {
[18]52    m_File->SeekEnd();
[16]53    if (m_File->Write(text) == false) {
54        m_Errors.Add(wxString::Format(_("Writing to: %s failed!"), m_File->GetName()));
55        return false;
56    }
57   
58    return true;
[15]59}
60
61
[16]62
63wxArrayString TmDmCopier::GetErrors(){
64    return m_Errors;
65}
Note: See TracBrowser for help on using the repository browser.