1/* 2 * Copyright 2004-2006, Jérôme Duval. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7#ifndef _EXPANDER_RULES_H 8#define _EXPANDER_RULES_H 9 10#include <File.h> 11#include <FilePanel.h> 12#include <List.h> 13#include <Mime.h> 14#include <String.h> 15 16 17class ExpanderRule { 18public: 19 ExpanderRule(const char* mimetype, 20 const BString& filenameExtension, 21 const BString& listingCommand, 22 const BString& expandCommand); 23 24 const BMimeType& MimeType() const 25 { return fMimeType; } 26 const BString& FilenameExtension() const 27 { return fFilenameExtension; } 28 const BString& ListingCmd() const 29 { return fListingCmd; } 30 const BString& ExpandCmd() const 31 { return fExpandCmd; } 32 33private: 34 BMimeType fMimeType; 35 BString fFilenameExtension; 36 BString fListingCmd; 37 BString fExpandCmd; 38}; 39 40 41class ExpanderRules { 42public: 43 ExpanderRules(); 44 ~ExpanderRules(); 45 46 ExpanderRule* MatchingRule(BString& fileName, 47 const char* filetype); 48 ExpanderRule* MatchingRule(const entry_ref* ref); 49 50private: 51 void _LoadRulesFiles(); 52 void _LoadRulesFile(const char* path); 53 54 bool _AddRule(const char* mimetype, 55 const BString& filenameExtension, 56 const BString& listingCommand, 57 const BString& expandCommand); 58 59private: 60 BList fList; 61}; 62 63 64class RuleRefFilter : public BRefFilter { 65public: 66 RuleRefFilter(ExpanderRules& rules); 67 bool Filter(const entry_ref* ref, BNode* node, 68 struct stat_beos* stat, 69 const char* filetype); 70 71protected: 72 ExpanderRules& fRules; 73}; 74 75 76#endif // _EXPANDER_RULES_H 77