1 /* 2 * Copyright 2004-2006, Jérôme Duval. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 #ifndef _ExpanderRules_h 7 #define _ExpanderRules_h 8 9 #include <List.h> 10 #include <File.h> 11 #include <String.h> 12 #include <Mime.h> 13 #include <FilePanel.h> 14 15 class ExpanderRule { 16 public: 17 ExpanderRule(BString mimetype, BString filenameExtension, 18 BString listingCmd, BString expandCmd); 19 ExpanderRule(const char* mimetype, const char* filenameExtension, 20 const char* listingCmd, const char* expandCmd); 21 BMimeType &MimeType() { return fMimeType;} 22 BString &FilenameExtension() { return fFilenameExtension;} 23 BString &ListingCmd() { return fListingCmd;} 24 BString &ExpandCmd() { return fExpandCmd;} 25 private: 26 BMimeType fMimeType; 27 BString fFilenameExtension; 28 BString fListingCmd; 29 BString fExpandCmd; 30 }; 31 32 33 class ExpanderRules { 34 public: 35 ExpanderRules(); 36 ~ExpanderRules(); 37 ExpanderRule *MatchingRule(BString &fileName, const char *filetype); 38 ExpanderRule *MatchingRule(const entry_ref *ref); 39 private: 40 status_t Open(BFile *file); 41 42 BList fList; 43 }; 44 45 46 class RuleRefFilter : public BRefFilter { 47 public: 48 RuleRefFilter(ExpanderRules &rules); 49 bool Filter(const entry_ref *ref, BNode* node, struct stat_beos *st, 50 const char *filetype); 51 protected: 52 ExpanderRules &fRules; 53 }; 54 55 #endif /* _ExpanderRules_h */ 56