]> git.vomp.tv Git - vompclient.git/blob - recording.cc
Connection failure detection
[vompclient.git] / recording.cc
1 /*
2     Copyright 2004-2005 Chris Tallon
3
4     This file is part of VOMP.
5
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.
10
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.
15
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
19 */
20
21 #include "recording.h"
22
23 Recording::Recording()
24 {
25   start = 0;
26   dirName = NULL;
27   progName = NULL;
28   fileName = NULL;
29
30   index = -1;
31 }
32
33 Recording::~Recording()
34 {
35   if (dirName) delete[] dirName;
36   if (progName) delete[] progName;
37   if (fileName) delete[] fileName;
38   index = -1; // just in case
39 }
40
41 int Recording::isInDir()
42 {
43 //  if (strstr(name, "~")) return 1;
44 //  else return 0;
45   return (dirName != NULL);
46 }
47
48 char* Recording::getDirName()
49 {
50 /*  char* sub = strstr(name, "~");
51   if (!sub) return NULL;
52
53   char* dirName = new char[sub - name + 1];
54   memcpy(dirName, name, sub - name);
55   dirName[sub - name] = '\0';
56   return dirName;
57 */
58   return dirName;
59 }
60
61 char* Recording::getProgName() const
62 {
63   return progName;
64 }
65
66 void Recording::setName(char* name)
67 {
68   char* sub = strstr(name, "~");
69
70   if (sub) // Its in a dir
71   {
72     dirName = new char[sub - name + 1];
73     memcpy(dirName, name, sub - name);
74     dirName[sub - name] = '\0';
75
76     sub++;
77     int sublen = strlen(sub);
78     progName = new char[sublen + 1];
79     memcpy(progName, sub, strlen(sub));
80     progName[sublen] = '\0';
81   }
82   else
83   {
84     int len = strlen(name);
85     progName = new char[len + 1];
86     memcpy(progName, name, len);
87     progName[len] = '\0';
88   }
89 }