2 * MP3/MPlayer plugin to VDR (C++)
4 * (C) 2001-2009 Stefan Huelswitt <s.huelswitt@gmx.de>
6 * This code is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This code is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
25 #include <vdr/tools.h>
27 // ----------------------------------------------------------------
31 extern char *Quote(const char *str);
32 extern char *AddPath(const char *dir, const char *filename);
33 extern bool CheckVDRVersion(int Version, int Major, int Minor, const char *text=0);
34 extern char *aprintf(const char *fmt, ...) __attribute__ ((format (printf,1,2)));
36 // ----------------------------------------------------------------
40 enum eScanType { stFile, stDir };
41 virtual void DoItem(cFileSource *src, const char *subdir, const char *name)=0;
43 virtual ~cScanDir() {}
44 bool ScanDir(cFileSource *src, const char *subdir, eScanType type, const char * const *spec, const char * const *excl, bool recursiv);
47 // ----------------------------------------------------------------
49 enum eObjType { otDir, otParent, otFile, otBase };
51 class cFileObj : public cListObject {
54 char *subdir, *name, *path, *fpath;
58 void MakeFullName(char **fp, const char *Name);
60 cFileObj(cFileSource *Source, const char *Subdir, const char *Name, const eObjType Type);
61 cFileObj(const cFileObj *obj);
63 virtual int Compare(const cListObject &ListObject) const;
64 void SetName(const char *Name);
65 void SplitAndSet(const char *Path);
69 bool TestName(const char *newName);
70 bool Rename(const char *newName);
71 bool Create(const char *newName);
74 inline const char *Name(void) const { return name; }
75 inline const char *Subdir(void) const { return subdir; }
76 inline cFileSource *Source(void) const { return source; }
77 inline eObjType Type(void) const { return type; }
78 inline const char *Path(void) const { return path; }
79 inline const char *FullPath(void) const { return fpath; }
82 // ----------------------------------------------------------------
84 class cDirList : public cScanDir, public cList<cFileObj> {
88 virtual void DoItem(cFileSource *src, const char *subdir, const char *name);
90 bool Load(cFileSource *src, const char *subdir, const char * const *excl=0);
93 // ----------------------------------------------------------------
95 class cFileSource : public cListObject {
97 enum eAction { acMount, acUnmount, acEject, acStatus };
98 char *basedir, *realbasedir;
102 int useCount, incCount;
103 // remember last browse position
104 char *browsedir, *browseparent;
106 void Set(const char *Basedir, const char *Description, const bool NeedsMount, const char *Include);
107 bool Action(eAction act);
108 void ClearRemember(void);
112 cFileSource(const char *Basedir, const char *Description, const bool NeedsMount, const char *Include=0);
119 void Block(void) { useCount++; }
120 void Unblock(void) { useCount--; }
121 void SetRemember(const char *dir, const char *parent);
122 bool GetRemember(char * &dir, char * &parent);
123 inline const char *BaseDir(void) const { return basedir; }
124 inline const char *RealBaseDir(void) const { return realbasedir; }
125 inline const char *Description(void) const { return description; }
126 inline const char * const * Include(void) const { return include; }
127 inline bool NeedsMount(void) const { return needsmount; }