2 * MP3/MPlayer plugin to VDR (C++)
4 * (C) 2001-2006 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 #if APIVERSNUM >= 10315
63 virtual int Compare(const cListObject &ListObject) const;
65 virtual bool operator<(const cListObject &ListObject);
67 void SetName(const char *Name);
68 void SplitAndSet(const char *Path);
72 bool TestName(const char *newName);
73 bool Rename(const char *newName);
74 bool Create(const char *newName);
77 inline const char *Name(void) const { return name; }
78 inline const char *Subdir(void) const { return subdir; }
79 inline cFileSource *Source(void) const { return source; }
80 inline eObjType Type(void) const { return type; }
81 inline const char *Path(void) const { return path; }
82 inline const char *FullPath(void) const { return fpath; }
85 // ----------------------------------------------------------------
87 class cDirList : public cScanDir, public cList<cFileObj> {
91 virtual void DoItem(cFileSource *src, const char *subdir, const char *name);
93 bool Load(cFileSource *src, const char *subdir, const char * const *excl=0);
96 // ----------------------------------------------------------------
98 class cFileSource : public cListObject {
100 enum eAction { acMount, acUnmount, acEject, acStatus };
101 char *basedir, *realbasedir;
105 int useCount, incCount;
106 // remember last browse position
107 char *browsedir, *browseparent;
109 void Set(const char *Basedir, const char *Description, const bool NeedsMount, const char *Include);
110 bool Action(eAction act);
111 void ClearRemember(void);
115 cFileSource(const char *Basedir, const char *Description, const bool NeedsMount, const char *Include=0);
122 void Block(void) { useCount++; }
123 void Unblock(void) { useCount--; }
124 void SetRemember(const char *dir, const char *parent);
125 bool GetRemember(char * &dir, char * &parent);
126 inline const char *BaseDir(void) const { return basedir; }
127 inline const char *RealBaseDir(void) const { return realbasedir; }
128 inline const char *Description(void) const { return description; }
129 inline const char * const * Include(void) const { return include; }
130 inline bool NeedsMount(void) const { return needsmount; }