Develop and Download Open Source Software

Browse CVS Repository

Diff of /malonnote/mnModel.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.29 by maloninc, Fri Dec 30 01:34:40 2005 UTC revision 1.32 by maloninc, Fri Oct 20 09:36:08 2006 UTC
# Line 3  Line 3 
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);
# Line 108  bool mnModel::matchWithToken(wxString* f Line 109  bool mnModel::matchWithToken(wxString* f
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;
# Line 461  WikiData::WikiData(wxString* dataDir, wx Line 492  WikiData::WikiData(wxString* dataDir, wx
492                  }                  }
493          }          }
494          fclose(fp);          fclose(fp);
495    
496            isWriteToFile = true;
497  }  }
498    
499  WikiData::WikiData(wxString* dataDir) {  WikiData::WikiData(wxString* dataDir) {
# Line 520  WikiData::WikiData(wxString* dataDir) { Line 553  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()
# Line 625  const wxString* WikiData::getText() Line 660  const wxString* WikiData::getText()
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());
# Line 724  void WikiData::save() Line 762  void WikiData::save()
762                    
763          free(inbuf);          free(inbuf);
764          free(outbuf);          free(outbuf);
765            
766            isWriteToFile = true;
767  }  }
768    
769  /******* Tools ************************/  /******* Tools ************************/

Legend:
Removed from v.1.29  
changed lines
  Added in v.1.32

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26