2 Copyright 2006 Chris Tallon
4 This file is part of VOMP.
6 VOMP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 VOMP 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 VOMP; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 rootDir = new Directory("/");
39 void RecMan::setStats(ULONG ttotalSpace, ULONG tfreeSpace, ULONG tusedPercent)
41 totalSpace = ttotalSpace;
42 freeSpace = tfreeSpace;
43 usedPercent = tusedPercent;
46 void RecMan::addEntry(ULONG startTime, char* name, char* fileName)
48 Recording* rec = new Recording();
49 rec->setStartTime(startTime);
50 rec->setFileName(fileName);
52 // And now for the directory structure & prog name
54 printf("%lu %s %s\n", startTime, name, fileName);
58 stack<char*> dirNamesStack;
60 bool gotProgName = false;
61 for(c = (name + strlen(name) - 1); c >= name; c--)
63 if ((*c == '~') || (c == name))
65 // Make d point to the start of the string (i.e. move on 1 from ~ if necessary)
66 if (c == name) d = name;
71 printf("Got prog name '%s'\n", d);
72 rec->setProgName(d); // will copy from d to end of string
79 oneDirName = new char[strlen(d) + 1];
80 strcpy(oneDirName, d);
81 dirNamesStack.push(oneDirName);
87 Directory* targetDirectory = rootDir;
90 while(!dirNamesStack.empty())
92 oneDirName = dirNamesStack.top();
93 if (!oneDirName) break;
95 getDir = targetDirectory->getDirByName(oneDirName);
98 targetDirectory = getDir;
102 printf("making new dir '%s'\n", oneDirName);
103 getDir = new Directory(oneDirName); // Make a new directory
104 getDir->parent = targetDirectory;
105 targetDirectory->dirList.push_back(getDir); // Put the new directory in the tree
106 targetDirectory = getDir; // Make the new dir the target
113 targetDirectory->recList.push_back(rec);
119 ULONG RecMan::getTotalSpace()
124 ULONG RecMan::getFreeSpace()
129 ULONG RecMan::getUsedPercent()
134 int RecMan::deleteRecording(Recording* rec)
138 for(RecordingList::iterator i = currentDir->recList.begin(); i != currentDir->recList.end(); i++)
142 success = VDR::getInstance()->deleteRecording(rec->getFileName());
145 currentDir->recList.erase(i);
155 bool RecMan::isSubDir()
157 return (currentDir != rootDir);
160 bool RecMan::down(Directory* downDir)
162 // Check dir is in currentDir
163 for(DirectoryList::iterator i = currentDir->dirList.begin(); i != currentDir->dirList.end(); i++)
167 currentDir = downDir;
176 if (!isSubDir()) return false;
178 Directory* oldDir = currentDir;
179 currentDir = currentDir->parent;
181 if (oldDir->getNumRecordings() == 0)
185 for (DirectoryList::iterator i = currentDir->dirList.begin(); i != currentDir->dirList.end(); i++)
188 if (tempdir == oldDir)
190 currentDir->dirList.erase(i);
200 char* RecMan::getCurDirName()
202 return currentDir->name;
205 DirectoryList* RecMan::getDirectories()
207 return ¤tDir->dirList;
210 RecordingList* RecMan::getRecordings()
212 return ¤tDir->recList;