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);
35 // ----------------------------------------------------------------
39 enum eScanType { stFile, stDir };
40 virtual void DoItem(cFileSource *src, const char *subdir, const char *name)=0;
42 virtual ~cScanDir() {}
43 bool ScanDir(cFileSource *src, const char *subdir, eScanType type, const char * const *spec, const char * const *excl, bool recursiv);
46 // ----------------------------------------------------------------
48 enum eObjType { otDir, otParent, otFile, otBase };
50 class cFileObj : public cListObject {
53 char *subdir, *name, *path, *fpath;
57 void MakeFullName(char **fp, const char *Name);
59 cFileObj(cFileSource *Source, const char *Subdir, const char *Name, const eObjType Type);
60 cFileObj(const cFileObj *obj);
62 virtual int Compare(const cListObject &ListObject) const;
63 void SetName(const char *Name);
64 void SplitAndSet(const char *Path);
68 bool TestName(const char *newName);
69 bool Rename(const char *newName);
70 bool Create(const char *newName);
73 inline const char *Name(void) const { return name; }
74 inline const char *Subdir(void) const { return subdir; }
75 inline cFileSource *Source(void) const { return source; }
76 inline eObjType Type(void) const { return type; }
77 inline const char *Path(void) const { return path; }
78 inline const char *FullPath(void) const { return fpath; }
81 // ----------------------------------------------------------------
83 class cDirList : public cScanDir, public cList<cFileObj> {
87 virtual void DoItem(cFileSource *src, const char *subdir, const char *name);
89 bool Load(cFileSource *src, const char *subdir, const char * const *excl=0);
92 // ----------------------------------------------------------------
94 class cFileSource : public cListObject {
96 enum eAction { acMount, acUnmount, acEject, acStatus };
97 char *basedir, *realbasedir;
101 int useCount, incCount;
102 // remember last browse position
103 char *browsedir, *browseparent;
105 void Set(const char *Basedir, const char *Description, const bool NeedsMount, const char *Include);
106 bool Action(eAction act);
107 void ClearRemember(void);
111 cFileSource(const char *Basedir, const char *Description, const bool NeedsMount, const char *Include=0);
118 void Block(void) { useCount++; }
119 void Unblock(void) { useCount--; }
120 void SetRemember(const char *dir, const char *parent);
121 bool GetRemember(char * &dir, char * &parent);
122 inline const char *BaseDir(void) const { return basedir; }
123 inline const char *RealBaseDir(void) const { return realbasedir; }
124 inline const char *Description(void) const { return description; }
125 inline const char * const * Include(void) const { return include; }
126 inline bool NeedsMount(void) const { return needsmount; }