| 3 |
#include <wx/dir.h> |
#include <wx/dir.h> |
| 4 |
#include <wx/regex.h> |
#include <wx/regex.h> |
| 5 |
#include <iconv.h> |
#include <iconv.h> |
| 6 |
|
#include <ctype.h> |
| 7 |
|
|
| 8 |
static void toLower(char* string); |
static void toLower(char* string); |
| 9 |
static char* decode(const char* string); |
static char* decode(const char* string); |
| 109 |
return ans; |
return ans; |
| 110 |
} |
} |
| 111 |
|
|
| 112 |
|
void mnModel::readAll( void ) |
| 113 |
|
{ |
| 114 |
|
int i; |
| 115 |
|
wxDir* dir; |
| 116 |
|
WikiData* wikiData; |
| 117 |
|
wxString* fileName = new wxString(); |
| 118 |
|
char* tokenList[MAX_TOKEN]; |
| 119 |
|
|
| 120 |
|
memset(tokenList, 0, sizeof(char*)*MAX_TOKEN); |
| 121 |
|
tokenList[0] = ""; |
| 122 |
|
|
| 123 |
|
dir = new wxDir(*wikiDataDir); |
| 124 |
|
if ( !dir->IsOpened() ) |
| 125 |
|
{ |
| 126 |
|
MN_FATAL_ERROR(wxT("wxDir has faild\n")); |
| 127 |
|
return ; |
| 128 |
|
} |
| 129 |
|
|
| 130 |
|
bool cont = dir->GetFirst(fileName, wxT("*.txt"), wxDIR_FILES); |
| 131 |
|
while(cont){ |
| 132 |
|
|
| 133 |
|
matchWithToken(fileName, tokenList); /* match with token list, but never match, just read. */ |
| 134 |
|
|
| 135 |
|
cont = dir->GetNext(fileName); |
| 136 |
|
} |
| 137 |
|
|
| 138 |
|
delete dir; |
| 139 |
|
delete fileName; |
| 140 |
|
} |
| 141 |
|
|
| 142 |
WikiList* mnModel::search(const char* searchStr) |
WikiList* mnModel::search(const char* searchStr) |
| 143 |
{ |
{ |
| 144 |
int i; |
int i; |
| 492 |
} |
} |
| 493 |
} |
} |
| 494 |
fclose(fp); |
fclose(fp); |
| 495 |
|
|
| 496 |
|
isWriteToFile = true; |
| 497 |
} |
} |
| 498 |
|
|
| 499 |
WikiData::WikiData(wxString* dataDir) { |
WikiData::WikiData(wxString* dataDir) { |
| 553 |
text = new wxString(buf, conv); |
text = new wxString(buf, conv); |
| 554 |
|
|
| 555 |
if(fp) fclose(fp); |
if(fp) fclose(fp); |
| 556 |
|
|
| 557 |
|
isWriteToFile = false; |
| 558 |
} |
} |
| 559 |
|
|
| 560 |
WikiData::~WikiData() |
WikiData::~WikiData() |
| 660 |
MN_FATAL_ERROR(wxT("failed iconv_open")); |
MN_FATAL_ERROR(wxT("failed iconv_open")); |
| 661 |
} |
} |
| 662 |
|
|
| 663 |
if(text) { |
if(text && isWriteToFile == true) { |
| 664 |
delete text; |
delete text; |
| 665 |
text = NULL; |
text = NULL; |
| 666 |
} |
} |
| 667 |
|
else if(text && isWriteToFile == false) { |
| 668 |
|
return text; |
| 669 |
|
} |
| 670 |
|
|
| 671 |
text = new wxString(); |
text = new wxString(); |
| 672 |
sprintf(fullPath, "%s/%s", (const char*)dataDirName->mb_str(), (const char*)fileName->mb_str()); |
sprintf(fullPath, "%s/%s", (const char*)dataDirName->mb_str(), (const char*)fileName->mb_str()); |
| 762 |
|
|
| 763 |
free(inbuf); |
free(inbuf); |
| 764 |
free(outbuf); |
free(outbuf); |
| 765 |
|
|
| 766 |
|
isWriteToFile = true; |
| 767 |
} |
} |
| 768 |
|
|
| 769 |
/******* Tools ************************/ |
/******* Tools ************************/ |