📄 file_type.cpp
字号:
/* * Copyright (C) 2006, Dung-Bang Tsai * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * * ( If you wnat to use this library for commercial use, * feel free to contact me, just cost some money, I could sell * you the code without GPL license, so you could use this code * for your product without public your source code. ) * * Authors: * Tsai, Dung-Bang <dbtsai@gmail.com> * * 2006/03/10 at NCKU physics */#include "file_type.h"#include<vector>wxString empty;enum{ Binary = 2, Text = 1, Unknow = -1};struct file_type{ wxString type; wxString describe; int id;};wxArrayString allow_text_type_table; file_type init[] = { {wxT("asp"),_T(""),1}, {wxT("bat"),_T(""),1}, {wxT("c"),_T(""),1}, {wxT("cfm"),_T(""),1} , {wxT("cgi"),_T(""),1}, {wxT("css"),_T(""),1} , {wxT("conf"),_T(""),1}, {wxT("dhtml"),_T(""),1} , {wxT("hpp"),_T(""),1}, {wxT("html"),_T(""),1} , {wxT("htm"),_T(""),1}, {wxT("in"),_T(""),1} , {wxT("inc"),_T(""),1}, {wxT("js"),_T(""),1} , {wxT("patch"),_T(""),1}, {wxT("php"),_T(""),1} , {wxT("phtml"),_T(""),1}, {wxT("pl"),_T(""),1} , {wxT("py"),_T(""),1}, {wxT("sh"),_T(""),1} , {wxT("shtml"),_T(""),1}, {wxT("sql"),_T(""),1}, {wxT("tcl"),_T(""),1}, {wxT("tpl"),_T(""),1} , {wxT("txt"),_T(""),1}, {wxT("vbs"),_T(""),1} , {wxT("xml"),_T(""),1}, {wxT("iso"),_T(""),2} , {wxT("exe"),_T(""),2}, {wxT("dll"),_T(""),2} };std::vector<file_type> file_type_table(init,init + sizeof(init)/sizeof(file_type) );wxString get_type(wxString filename){ wxString type; wxStringTokenizer token(filename,wxT(".")); if(token.CountTokens()==1) type = wxEmptyString; else { while( token.HasMoreTokens() ) { type = token.GetNextToken(); } } return type;}bool is_allow_text_type(wxString type,wxString& filetype ){ //cout <<type.mb_str(wxConvUTF8) << endl; std::vector<file_type>::iterator begin = file_type_table.begin(); const std::vector<file_type>::iterator end = file_type_table.end(); for(;begin!=end;begin++) { if(begin->type == type ) { if( begin->id = Text) { filetype = begin->describe; if(filetype == wxT("")) filetype = _T("純文字檔"); return true; } else { filetype = begin->describe; if(filetype == wxT("")) filetype = _T("未知類型"); return false; } } } filetype = _T("未知類型"); return false;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -