The Fib multimedia system
Fib is a system for storing multimedia data (like images or films).
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
cFolder.h
Go to the documentation of this file.
1 /**
2  * @file cFolder
3  * file name: cFolder.h
4  * @author Betti Oesterholz
5  * @date 07.02.2010
6  * @mail webmaster@BioKom.info
7  *
8  * System: C++
9  *
10  * This class represents a folder.
11  *
12  * Copyright (C) @c GPL3 2010 Betti Oesterholz
13  *
14  * This program is free software: you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation, either version 3 of the License, or
17  * any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program. If not, see <http://www.gnu.org/licenses/>.
26  *
27  *
28  * This class represents a folder.
29  * You can get the information about a folder and it's entries with it.
30  *
31  */
32 /*
33 History:
34 07.02.2010 Oesterholz created
35 */
36 
37 
38 
39 #ifndef ___C_FOLDER_H__
40 #define ___C_FOLDER_H__
41 
42 
43 
44 #include <string>
45 #include <list>
46 
47 #include <dirent.h>
48 #include <sys/types.h>
49 #include <sys/stat.h>
50 
51 
52 using namespace std;
53 
54 
55 
56 class cFolder{
57 protected:
58 
59  /**
60  * The path of the folder this class represents.
61  */
62  string szFolderName;
63 
64  /**
65  * If the folder, this class represents, is accessible.
66  */
67  bool bGood;
68 
69  /**
70  * The list of the entries of the folder, with ther information.
71  */
72  list< pair<string, struct stat> > liEntryInfo;
73 
74  /**
75  * The list of subfolders in the folder.
76  */
77  list<string> liSubFolders;
78 
79  /**
80  * The list of (regular) files in the folder.
81  */
82  list<string> liFiles;
83 
84 
85 public:
86 
87  /**
88  * constructor
89  *
90  * @param szFolderName the path of the folder this object should represent
91  */
92  cFolder( const char * szFolderName );
93 
94  /**
95  * constructor
96  *
97  * @param szFolderName the path of the folder this object should represent
98  */
99  cFolder( const string & szFolderName );
100 
101  /**
102  * Updates the data of the folder.
103  * This means the folder information is reread.
104  */
105  bool update();
106 
107  /**
108  * @return true if the folder, this class represents, is accessible, else false
109  */
110  bool good() const;
111 
112  /**
113  * Returns the entryinformation for the entry with the given number.
114  *
115  * @param uiEntryNumber the number of the entry, for which the information
116  * is to be returned
117  * @return the information to the uiEntryNumber'th entry in the folder
118  */
119  struct stat getInfo( unsigned int uiEntryNumber ) const;
120 
121  /**
122  * Returns the entryinformation for the entry with the given name.
123  *
124  * @param szEntryName the name of the entry, for which the information
125  * is to be returned
126  * @return the information to the entry with the given name szEntryName
127  */
128  struct stat getInfo( const string & szEntryName ) const;
129 
130  /**
131  * This method returns the size (in byts) of the folderentry with the
132  * given name szEntryName.
133  *
134  * @param szEntryName the name of the entry, for which the size
135  * is to be returned
136  * @return the size in byts of the entry with given name szEntryName,
137  * or 0 if the entry didn't exists or has no size
138  */
139  unsigned long getSize( const string & szEntryName ) const;
140 
141  /**
142  * This method returns the user id of the folderentry with the
143  * given name szEntryName.
144  *
145  * @param szEntryName the name of the entry, for which the user id
146  * is to be returned
147  * @return the user id of the entry with given name szEntryName,
148  * or 0 if the entry didn't exists or has no size
149  */
150  unsigned int getUserId( const string & szEntryName ) const;
151 
152  /**
153  * This method returns the group id of the folderentry with the
154  * given name szEntryName.
155  *
156  * @param szEntryName the name of the entry, for which the group id
157  * is to be returned
158  * @return the group id of the entry with given name szEntryName,
159  * or 0 if the entry didn't exists or has no size
160  */
161  unsigned int getGroupId( const string & szEntryName ) const;
162 
163  /**
164  * This method returns the time the folderentry with the given name
165  * szEntryName was last accessed.
166  *
167  * @param szEntryName the name of the entry, for which the last access
168  * time is to be returned
169  * @return the time of the last access of the entry with given name
170  * szEntryName, or 0 if the entry didn't exists
171  */
172  time_t getLastAccessTime( const string & szEntryName ) const;
173 
174  /**
175  * This method returns the time the folderentry with the given name
176  * szEntryName was last changed.
177  *
178  * @param szEntryName the name of the entry, for which the last changed
179  * time is to be returned
180  * @return the time of the last changed of the entry with given name
181  * szEntryName, or 0 if the entry didn't exists
182  */
183  time_t getLastChangeTime( const string & szEntryName ) const;
184 
185  /**
186  * This method returns the time status of the folderentry with the given
187  * name szEntryName was last changed.
188  *
189  * @param szEntryName the name of the entry, for which the last status
190  * changed time is to be returned
191  * @return the time of the last status changed of the entry with given name
192  * szEntryName, or 0 if the entry didn't exists
193  */
194  time_t getLastStatusChangeTime( const string & szEntryName ) const;
195 
196  /**
197  * @return a list with the names of all entries in the folder
198  */
199  list<string> getAllEntries() const;
200 
201 
202  /**
203  * @return a list with the names of all subfolders in the folder
204  */
205  list<string> getSubFolders() const;
206 
207 
208  /**
209  * @return a list with the names of all (regular) files in the folder
210  */
211  list<string> getFiles() const;
212 
213 
214 
215 };//cFolder
216 
217 #endif //___C_FOLDER_H__
218 
219 
220 
221 
222 
223 
224 
225