00001 00002 // Name: mswfiletypes.h 00003 // Author: Joe Yates 00004 // Purpose: WIN32 file type information interface 00005 // Created: 2004-11-25 00006 // Copyright: (c) Joe Yates 00007 // License: BSD license (see the file 'LICENSE.txt') 00009 00010 #ifndef __msw_filetypes_h__ 00011 #define __msw_filetypes_h__ 00012 00013 #include "wx/defs.h" 00014 #include "wx/string.h" 00015 #include "wx/filetypes.h" 00016 #include <wx/filename.h> 00017 00018 #include <map> 00019 00020 class wxWindowsFileTypes : public wxFileTypesImpl 00021 { 00022 private: 00023 class ExtensionCache : public std::map<wxString, wxArrayString *> 00024 { 00025 public: 00026 ~ExtensionCache() 00027 { 00028 } 00029 }; 00030 class ClassCache : public std::map<wxString, wxString> 00031 { 00032 public: 00033 ~ClassCache() 00034 { 00035 } 00036 }; 00037 00038 public: 00039 wxWindowsFileTypes(); 00040 ~wxWindowsFileTypes() 00041 { 00042 UnloadCaches(); 00043 }; 00044 00045 bool IsLoaded() const; 00046 wxString GetFileType(const wxString& sFileURL) const; 00047 wxFileType2 LoadFileType(const wxString& sFileType) const; 00048 bool SaveFileType(const wxFileType2& fti) const; 00049 00050 wxArrayString GetApplications(const wxString& sFileURL) const; 00051 bool AddApplication(const wxString& sFileURL, const wxString& sNewApplication) const; 00052 bool RemoveApplication(const wxString& sFileURL, const wxString& sApplication) const; 00053 wxString GetCommand(const wxString& sApplicationId) const; 00054 bool SetCommand(const wxString& sApplicationId, const wxString& sNewCommand) const; 00055 00056 // TBI: should simply derive from wxObject and use its RTTI 00057 wxString GetTypeName() const; 00058 //wxFileType2 LoadInfo(const wxString& sFileType) const; 00059 00060 private: 00061 wxString GetDescription(const wxString& sFileType) const; 00062 wxFileName GetImagePath(const wxString& sFileType) const; 00063 wxString GetDefaultCommand(const wxString& sFileType) const; 00064 wxArrayString GetExtensions(const wxString& sFileType) const; 00065 00066 wxString GetClassFromExtension(const wxString& sExtension) const; 00067 00068 // Caches 00069 void LoadCaches(); 00070 void UnloadCaches(); 00071 00072 private: 00073 ClassCache * cls; 00074 ExtensionCache * ext; 00075 }; 00076 00077 #endif 00078 // ndef __msw_filetypes_h__