1 // Base class for a filesystem hook module which depends on filename.
2 // default behaviour filters on extension.
6 // call this function with true it the file we are looking at has already been processed by another
7 // filter. Returns true if this filter wants to process it too.
8 virtual bool CanAdd( bool already_added ) { return !already_added; };
10 /* If this module can process this file, this method will return a "virtual"
11 file name for the processed file. Else, returns empty string.
12 example : fname = "music.flac" => returns "music.flac$.wav" */
13 virtual string GetVirtualFilename(const char* fname);
15 // returns true if it is this module which generated this virtual filename
16 virtual bool IsMyVirtualFilename(const char* fname);
18 // returns real filename from virtual filename, or empty string if impossible
19 virtual string GetRealFilename( const char* virtuel );
21 // Opens a file and returns a handle to it. NULL if error.
22 virtual FileHandle* Open( const char* path );
25 virtual const char* GetRealExtension() { return ""; }
28 virtual const char* GetVirtualExtension() { return ""; }
30 typedef vector<FSModule*> Array;
32 virtual const char* Identity() { return "FSModule"; }
35 virtual FileHandle* CreateHandle(const char* name, const char* real_name) =0;
39 class FSModule_Default : public FSModule
42 virtual string GetVirtualFilename(const char* fname);
43 bool IsMyVirtualFilename(const char* fname);
44 string GetRealFilename( const char* virtuel );
45 FileHandle* CreateHandle(const char* name, const char* real_name) { return new FileHandle_Default(name,real_name); }
46 virtual const char* Identity() { return "FSModule_Default"; }
49 class FSModule_Flac : public FSModule
52 const char* GetRealExtension() { return ".flac"; }
53 const char* GetVirtualExtension() { return ".wav"; }
54 FileHandle* CreateHandle(const char* name, const char* real_name) { return new FileHandle_Flac(name,real_name); }
55 virtual const char* Identity() { return "FSModule_Flac"; }
59 class FSModule_Ogg : public FSModule
62 const char* GetRealExtension() { return ".ogg"; }
63 const char* GetVirtualExtension() { return ".wav"; }
64 FileHandle* CreateHandle(const char* name, const char* real_name) { return new FileHandle_Ogg(name,real_name); }
65 virtual const char* Identity() { return "FSModule_Ogg"; }
68 class FSModule_MP3 : public FSModule
71 const char* GetRealExtension() { return ".mp3"; }
72 const char* GetVirtualExtension() { return ".wav"; }
73 FileHandle* CreateHandle(const char* name, const char* real_name) { return new FileHandle_MP3(name,real_name); }
74 virtual const char* Identity() { return "FSModule_MP3"; }