| 2 |
#include "mnModel.h" |
#include "mnModel.h" |
| 3 |
#include <wx/dir.h> |
#include <wx/dir.h> |
| 4 |
#include <wx/regex.h> |
#include <wx/regex.h> |
| 5 |
|
#include <wx/progdlg.h> |
| 6 |
#include <iconv.h> |
#include <iconv.h> |
| 7 |
#include <ctype.h> |
#include <ctype.h> |
| 8 |
|
|
| 110 |
return ans; |
return ans; |
| 111 |
} |
} |
| 112 |
|
|
| 113 |
void mnModel::readAll( void ) |
void mnModel::readAll(wxString* title, bool progBarFlag) |
| 114 |
{ |
{ |
| 115 |
int i; |
int fileCount = 0; |
| 116 |
wxDir* dir; |
wxDir* dir; |
| 117 |
WikiData* wikiData; |
WikiData* wikiData; |
| 118 |
wxString* fileName = new wxString(); |
wxString* fileName = new wxString(); |
| 119 |
char* tokenList[MAX_TOKEN]; |
char* tokenList[MAX_TOKEN]; |
| 120 |
|
bool cont; |
| 121 |
|
wxProgressDialog* progBar; |
| 122 |
|
|
| 123 |
memset(tokenList, 0, sizeof(char*)*MAX_TOKEN); |
memset(tokenList, 0, sizeof(char*)*MAX_TOKEN); |
| 124 |
tokenList[0] = ""; |
tokenList[0] = ""; |
| 129 |
MN_FATAL_ERROR(wxT("wxDir has faild\n")); |
MN_FATAL_ERROR(wxT("wxDir has faild\n")); |
| 130 |
return ; |
return ; |
| 131 |
} |
} |
| 132 |
|
|
| 133 |
|
/* count number of files */ |
| 134 |
|
if (progBarFlag) { |
| 135 |
|
cont = dir->GetFirst(fileName, wxT("*.txt"), wxDIR_FILES); |
| 136 |
|
while(cont){ |
| 137 |
|
fileCount++; |
| 138 |
|
cont = dir->GetNext(fileName); |
| 139 |
|
} |
| 140 |
|
progBar = new wxProgressDialog(wxT("Loading Data"), (wxT("Now loading... ") + *title), fileCount); |
| 141 |
|
} |
| 142 |
|
|
| 143 |
bool cont = dir->GetFirst(fileName, wxT("*.txt"), wxDIR_FILES); |
fileCount = 0; |
| 144 |
|
cont = dir->GetFirst(fileName, wxT("*.txt"), wxDIR_FILES); |
| 145 |
while(cont){ |
while(cont){ |
| 146 |
|
fileCount++; |
| 147 |
|
if (progBarFlag) progBar->Update(fileCount); |
| 148 |
matchWithToken(fileName, tokenList); /* match with token list, but never match, just read. */ |
matchWithToken(fileName, tokenList); /* match with token list, but never match, just read. */ |
|
|
|
| 149 |
cont = dir->GetNext(fileName); |
cont = dir->GetNext(fileName); |
| 150 |
} |
} |
| 151 |
|
|
| 152 |
|
delete progBar; |
| 153 |
delete dir; |
delete dir; |
| 154 |
delete fileName; |
delete fileName; |
| 155 |
} |
} |