|
a/libupnpp/device/vdir.hxx |
|
b/libupnpp/device/vdir.hxx |
1 |
/* Copyright (C) 2014 J.F.Dockes
|
1 |
/* Copyright (C) 2014 J.F.Dockes
|
2 |
* This program is free software; you can redistribute it and/or modify
|
2 |
* This program is free software; you can redistribute it and/or modify
|
3 |
* it under the terms of the GNU General Public License as published by
|
3 |
* it under the terms of the GNU General Public License as published by
|
4 |
* the Free Software Foundation; either version 2 of the License, or
|
4 |
* the Free Software Foundation; either version 2 of the License, or
|
5 |
* (at your option) any later version.
|
5 |
* (at your option) any later version.
|
6 |
*
|
6 |
*
|
7 |
* This program is distributed in the hope that it will be useful,
|
7 |
* This program is distributed in the hope that it will be useful,
|
8 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
8 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
9 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
10 |
* GNU General Public License for more details.
|
10 |
* GNU General Public License for more details.
|
11 |
*
|
11 |
*
|
12 |
* You should have received a copy of the GNU General Public License
|
12 |
* You should have received a copy of the GNU General Public License
|
13 |
* along with this program; if not, write to the
|
13 |
* along with this program; if not, write to the
|
14 |
* Free Software Foundation, Inc.,
|
14 |
* Free Software Foundation, Inc.,
|
15 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
15 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
16 |
*/
|
16 |
*/
|
17 |
|
17 |
|
18 |
#ifndef _VDIR_H_X_INCLUDED_
|
18 |
#ifndef _VDIR_H_X_INCLUDED_
|
19 |
#define _VDIR_H_X_INCLUDED_
|
19 |
#define _VDIR_H_X_INCLUDED_
|
20 |
|
20 |
|
21 |
/** An easy libupnp virtual directory handler, based on stl
|
21 |
/** An easy libupnp virtual directory handler, based on stl
|
22 |
maps and strings.
|
22 |
maps and strings.
|
23 |
|
23 |
|
24 |
As libupnp only lets us defines the api calls (open/read/etc.),
|
24 |
As libupnp only lets us defines the api calls (open/read/etc.),
|
25 |
without any data cookie, this has to be a global singleton object.
|
25 |
without any data cookie, this has to be a global singleton object.
|
26 |
*/
|
26 |
*/
|
|
... |
|
... |
28 |
#include <time.h>
|
28 |
#include <time.h>
|
29 |
|
29 |
|
30 |
#include <string>
|
30 |
#include <string>
|
31 |
#include <unordered_map>
|
31 |
#include <unordered_map>
|
32 |
|
32 |
|
|
|
33 |
namespace UPnPProvider {
|
|
|
34 |
|
33 |
class VirtualDir {
|
35 |
class VirtualDir {
|
34 |
public:
|
36 |
public:
|
35 |
static VirtualDir* getVirtualDir();
|
37 |
static VirtualDir* getVirtualDir();
|
36 |
bool addFile(const std::string& path, const std::string& name,
|
38 |
bool addFile(const std::string& path, const std::string& name,
|
37 |
const std::string& content, const std::string& mimetype);
|
39 |
const std::string& content, const std::string& mimetype);
|
38 |
class FileEnt {
|
40 |
class FileEnt {
|
39 |
public:
|
41 |
public:
|
40 |
time_t mtime;
|
42 |
time_t mtime;
|
41 |
std::string mimetype;
|
43 |
std::string mimetype;
|
42 |
std::string content;
|
44 |
std::string content;
|
43 |
};
|
45 |
};
|
44 |
FileEnt *getFile(const std::string& path, const std::string& name);
|
46 |
FileEnt *getFile(const std::string& path, const std::string& name);
|
45 |
|
47 |
|
46 |
private:
|
48 |
private:
|
47 |
VirtualDir() {}
|
49 |
VirtualDir() {}
|
48 |
|
50 |
|
49 |
std::unordered_map<std::string, std::unordered_map<std::string, FileEnt> >
|
51 |
std::unordered_map<std::string, std::unordered_map<std::string, FileEnt> >
|
50 |
m_dirs;
|
52 |
m_dirs;
|
51 |
};
|
53 |
};
|
52 |
|
54 |
|
|
|
55 |
}
|
53 |
|
56 |
|
54 |
#endif /* _VDIR_H_X_INCLUDED_ */
|
57 |
#endif /* _VDIR_H_X_INCLUDED_ */
|
55 |
|
|
|
56 |
/* Local Variables: */
|
|
|
57 |
/* mode: c++ */
|
|
|
58 |
/* c-basic-offset: 4 */
|
|
|
59 |
/* tab-width: 4 */
|
|
|
60 |
/* indent-tabs-mode: t */
|
|
|
61 |
/* End: */
|
|
|