--- a/libupnpp/vdir.cxx
+++ b/libupnpp/vdir.cxx
@@ -22,6 +22,7 @@
#include "upnpplib.hxx"
#include "upnpp_p.hxx"
#include "vdir.hxx"
+#include "log.hxx"
using namespace std;
@@ -56,10 +57,10 @@
static int vdgetinfo(const char *fn, struct File_Info* info )
{
- //cerr << "vdgetinfo: " << fn << endl;
+ //LOGDEB("vdgetinfo: " << fn << endl);
VirtualDir::FileEnt *entry = vdgetentry(fn);
if (entry == 0) {
- cerr << "vdgetinfo: no entry for " << fn << endl;
+ LOGERR("vdgetinfo: no entry for " << fn << endl);
return -1;
}
info->file_length = entry->content.size();
@@ -69,12 +70,13 @@
info->content_type = ixmlCloneDOMString(entry->mimetype.c_str());
return 0;
}
+
static UpnpWebFileHandle vdopen(const char* fn, enum UpnpOpenFileMode Mode)
{
- //cerr << "vdopen: " << fn << endl;
+ //LOGDEB("vdopen: " << fn << endl);
VirtualDir::FileEnt *entry = vdgetentry(fn);
if (entry == 0) {
- cerr << "vdopen: no entry for " << fn << endl;
+ LOGERR("vdopen: no entry for " << fn << endl);
return NULL;
}
return new Handle(entry);
@@ -82,7 +84,7 @@
static int vdread(UpnpWebFileHandle fileHnd, char* buf, size_t buflen)
{
- // cerr << "vdread: " << endl;
+ // LOGDEB("vdread: " << endl);
if (buflen == 0)
return 0;
Handle *h = (Handle *)fileHnd;
@@ -97,7 +99,7 @@
static int vdseek(UpnpWebFileHandle fileHnd, long offset, int origin)
{
- // cerr << "vdseek: " << endl;
+ // LOGDEB("vdseek: " << endl);
Handle *h = (Handle *)fileHnd;
if (origin == 0)
h->offset = offset;
@@ -109,9 +111,10 @@
return -1;
return offset;
}
+
static int vdwrite(UpnpWebFileHandle fileHnd, char* buf, size_t buflen)
{
- // cerr << "vdwrite" << endl;
+ LOGERR("vdwrite" << endl);
return -1;
}
@@ -124,7 +127,7 @@
if (theDir == 0) {
theDir = new VirtualDir();
if (UpnpSetVirtualDirCallbacks(&myvdcalls) != UPNP_E_SUCCESS) {
- cerr<< "SetVirtualDirCallbacks failed" << endl;
+ LOGERR("SetVirtualDirCallbacks failed" << endl);
delete theDir;
theDir = 0;
return 0;
@@ -141,7 +144,7 @@
path += '/';
}
if (m_dirs.find(path) == m_dirs.end()) {
- m_dirs[path] = map<string, VirtualDir::FileEnt>();
+ m_dirs[path] = unordered_map<string, VirtualDir::FileEnt>();
UpnpAddVirtualDir(path.c_str());
}
VirtualDir::FileEnt entry;
@@ -149,8 +152,8 @@
entry.mimetype = mimetype;
entry.content = content;
m_dirs[path][name] = entry;
- // cerr << "VirtualDir::addFile: added entry for dir " <<
- // path << " name " << name << endl;
+ // LOGDEB("VirtualDir::addFile: added entry for dir " <<
+ // path << " name " << name << endl);
}
VirtualDir::FileEnt *VirtualDir::getFile(const string& _path,
@@ -161,17 +164,17 @@
path += '/';
}
- // cerr << "VirtualDir::getFile: path " << path << " name " << name << endl;
+ // LOGDEB("VirtualDir::getFile: path " << path << " name " << name << endl);
- map<string, map<string,VirtualDir::FileEnt> >::iterator dir =
+ unordered_map<string, unordered_map<string,VirtualDir::FileEnt> >::iterator dir =
m_dirs.find(path);
if (dir == m_dirs.end()) {
- cerr << "VirtualDir::getFile: no dir: " << path << endl;
+ LOGERR("VirtualDir::getFile: no dir: " << path << endl);
return 0;
}
- map<string, FileEnt>::iterator f = dir->second.find(name);
+ unordered_map<string, FileEnt>::iterator f = dir->second.find(name);
if (f == dir->second.end()) {
- cerr << "VirtualDir::getFile: no file: " << path << endl;
+ LOGERR("VirtualDir::getFile: no file: " << path << endl);
return 0;
}