Ignore:
Timestamp:
02/21/13 16:20:42 (12 years ago)
Author:
lucsch
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tmdmcreator/src/tmdmcreator.cpp

    r15 r16  
    1616 
    1717#include "tmdmcreator.h" 
     18#include "tmdmcopier.h" 
    1819 
    19 tmdmcreator::tmdmcreator() { 
     20TmDmCreator::TmDmCreator() { 
    2021} 
    2122 
    2223 
    2324 
    24 tmdmcreator::~tmdmcreator() { 
     25TmDmCreator::~TmDmCreator() { 
    2526} 
    2627 
    2728 
    2829 
    29 void tmdmcreator::SetBaseSQL(wxFileName value) { 
     30void TmDmCreator::SetBaseSQL(wxFileName value) { 
    3031  m_FileNameBaseSQL = value; 
    3132} 
     
    3334 
    3435 
    35 void tmdmcreator::SetUserSQL(wxFileName value) { 
     36void TmDmCreator::SetUserSQL(wxFileName value) { 
    3637  m_FileNameUserSQL = value; 
    3738} 
     
    3940 
    4041 
    41 void tmdmcreator::SetUserContent(wxFileName value) { 
     42void TmDmCreator::SetUserContent(wxFileName value) { 
    4243  m_FileNameUserContent = value; 
    4344} 
     
    4546 
    4647 
    47 void tmdmcreator::SetOutSQL(wxFileName value) { 
     48void TmDmCreator::SetOutSQL(wxFileName value) { 
    4849  m_FileNameOutSQL = value; 
    4950} 
    5051 
    5152 
    52  
    53 bool tmdmcreator::CheckFiles(wxArrayString & errormsg) { 
    54     return false; 
     53bool TmDmCreator::_CheckExistsAndExt(const wxFileName & filename, const wxString & extension, wxArrayString * errormsg){ 
     54    wxASSERT(errormsg); 
     55    if (filename.Exists() == false) { 
     56        errormsg->Add(wxString::Format(_("File: %s didn't exists!"), filename.GetFullPath())); 
     57        return false; 
     58    } 
     59    if (filename.GetExt().Lower() != extension) { 
     60        errormsg->Add(wxString::Format(_("Wrong extension for: %s  (expected: %s)"), filename.GetFullPath(), extension)); 
     61        return false; 
     62    } 
     63    return true; 
    5564} 
    5665 
    5766 
    5867 
    59 bool tmdmcreator::ProcessFiles(wxArrayString & errorsmsg) { 
    60     return false; 
     68bool TmDmCreator::CheckFiles(wxArrayString & errormsg) { 
     69    errormsg.Clear(); 
     70    if (_CheckExistsAndExt(m_FileNameBaseSQL, _T("sql"), &errormsg) == false) { 
     71        return false; 
     72    } 
     73    if (_CheckExistsAndExt(m_FileNameUserSQL, _T("sql"), &errormsg) == false) { 
     74        return false; 
     75    } 
     76    if (_CheckExistsAndExt(m_FileNameUserContent, _T("txt"), &errormsg) == false) { 
     77        return false; 
     78    } 
     79    if (m_FileNameOutSQL.Exists()) { 
     80        errormsg.Add(wxString::Format(_("output file: %s allready exists!"), m_FileNameOutSQL.GetFullPath())); 
     81        return false; 
     82    } 
     83    if (m_FileNameOutSQL.IsDirWritable() == false){ 
     84        errormsg.Add(wxString::Format(_T("Writing not permitted into %s"), m_FileNameOutSQL.GetPath())); 
     85        return false; 
     86    } 
     87    return true; 
    6188} 
    6289 
     90 
     91 
     92bool TmDmCreator::ProcessFiles(wxArrayString & errorsmsg) { 
     93    errorsmsg.Clear(); 
     94    // Copy structure to out 
     95    TmDmCopier myCopier(m_FileNameOutSQL); 
     96    if (myCopier.CopyFrom(m_FileNameBaseSQL) == false) { 
     97        errorsmsg.Add(wxString::Format(_("Copying: %s failed!"), m_FileNameBaseSQL.GetFullPath())); 
     98        return false; 
     99    } 
     100     
     101    if (myCopier.CopyFrom(m_FileNameUserSQL) == false) { 
     102        errorsmsg.Add(wxString::Format(_("Copying: %s failed!"), m_FileNameUserSQL.GetFullPath())); 
     103        return false; 
     104    } 
     105     
     106     
     107     
     108    return true; 
     109} 
     110 
Note: See TracChangeset for help on using the changeset viewer.