summaryrefslogtreecommitdiff
path: root/cmps
diff options
context:
space:
mode:
authorgeronimo <geronimo013@gmx.de>2012-07-25 06:38:28 +0200
committergeronimo <geronimo013@gmx.de>2012-07-25 06:38:28 +0200
commit774e09eef2d7761814e6f19fb462eb0fdc74f2d7 (patch)
treeca0c4e06afdb99139c7953a8dd5576a3bcd15e23 /cmps
parentab7186c6c116629983dc506c4b53794026518455 (diff)
downloadcmp-774e09eef2d7761814e6f19fb462eb0fdc74f2d7.tar.gz
cmp-774e09eef2d7761814e6f19fb462eb0fdc74f2d7.tar.bz2
worked out different file class and improved media handling
Diffstat (limited to 'cmps')
-rw-r--r--cmps/main.cc13
-rw-r--r--cmps/serverlib/include/HTMLListAssembler.h14
-rw-r--r--cmps/serverlib/include/HTTPMediaResponse.h14
-rw-r--r--cmps/serverlib/serverlib.layout4
-rw-r--r--cmps/serverlib/serverlib.layout.save10
-rw-r--r--cmps/serverlib/src/HTMLListAssembler.cc50
-rw-r--r--cmps/serverlib/src/JSonListAssembler.cc31
-rw-r--r--cmps/serverlib/src/MediaFileHandler.cc14
-rw-r--r--cmps/tests/FScanTest.cc15
-rw-r--r--cmps/tests/FileSystemTest.cc198
10 files changed, 247 insertions, 116 deletions
diff --git a/cmps/main.cc b/cmps/main.cc
index 86e14b7..d897ab8 100644
--- a/cmps/main.cc
+++ b/cmps/main.cc
@@ -1,25 +1,25 @@
/**
* ======================== legal notice ======================
- *
+ *
* File: main.cc
* Created: 2. Juli 2012, 16
* Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
* Project: cmps - the backend (server) part of compound media player
- *
+ *
* CMP - compound media player
- *
+ *
* is a client/server mediaplayer intended to play any media from any workstation
* without the need to export or mount shares. cmps is an easy to use backend
* with a (ready to use) HTML-interface. Additionally the backend supports
* authentication via HTTP-digest authorization.
* cmpc is a client with vdr-like osd-menues.
- *
+ *
* Copyright (c) 2012 Reinhard Mantey, some rights reserved!
* published under Creative Commons by-sa
* For details see http://creativecommons.org/licenses/by-sa/3.0/
- *
+ *
* The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp
- *
+ *
* --------------------------------------------------------------
*/
#include <HTTPServer.h>
@@ -150,6 +150,7 @@ int main(int argc, char** argv)
cCommandHandler::Cleanup();
free((void *)cHTTPResponse::ServerID());
cUrl::Cleanup();
+ cFile::Cleanup();
delete scanner;
delete server;
diff --git a/cmps/serverlib/include/HTMLListAssembler.h b/cmps/serverlib/include/HTMLListAssembler.h
index 8450130..2b8fa65 100644
--- a/cmps/serverlib/include/HTMLListAssembler.h
+++ b/cmps/serverlib/include/HTMLListAssembler.h
@@ -1,25 +1,25 @@
/**
* ======================== legal notice ======================
- *
+ *
* File: HTMLListAssembler.h
* Created: 6. Juli 2012, 09
* Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
* Project: cmps - the backend (server) part of compound media player
- *
+ *
* CMP - compound media player
- *
+ *
* is a client/server mediaplayer intended to play any media from any workstation
* without the need to export or mount shares. cmps is an easy to use backend
* with a (ready to use) HTML-interface. Additionally the backend supports
* authentication via HTTP-digest authorization.
* cmpc is a client with vdr-like osd-menues.
- *
+ *
* Copyright (c) 2012 Reinhard Mantey, some rights reserved!
* published under Creative Commons by-sa
* For details see http://creativecommons.org/licenses/by-sa/3.0/
- *
+ *
* The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp
- *
+ *
* --------------------------------------------------------------
*/
#ifndef HTMLLISTASSEMBLER_H
@@ -48,7 +48,7 @@ private:
cStringBuilder &genNextLink(cStringBuilder &sb, int n);
cStringBuilder &genPreviousLink(cStringBuilder &sb, int n);
cStringBuilder &genTypeMenu(cStringBuilder &sb, std::map<int, size_t> &Categories);
-};
+ };
#endif /* HTMLLISTASSEMBLER_H */
diff --git a/cmps/serverlib/include/HTTPMediaResponse.h b/cmps/serverlib/include/HTTPMediaResponse.h
index b1ac4ca..298f43c 100644
--- a/cmps/serverlib/include/HTTPMediaResponse.h
+++ b/cmps/serverlib/include/HTTPMediaResponse.h
@@ -1,25 +1,25 @@
/**
* ======================== legal notice ======================
- *
+ *
* File: HTTPMediaResponse.h
* Created: 6. Juli 2012, 07
* Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
* Project: cmps - the backend (server) part of compound media player
- *
+ *
* CMP - compound media player
- *
+ *
* is a client/server mediaplayer intended to play any media from any workstation
* without the need to export or mount shares. cmps is an easy to use backend
* with a (ready to use) HTML-interface. Additionally the backend supports
* authentication via HTTP-digest authorization.
* cmpc is a client with vdr-like osd-menues.
- *
+ *
* Copyright (c) 2012 Reinhard Mantey, some rights reserved!
* published under Creative Commons by-sa
* For details see http://creativecommons.org/licenses/by-sa/3.0/
- *
+ *
* The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp
- *
+ *
* --------------------------------------------------------------
*/
#ifndef HTTPMEDIARESPONSE_H
@@ -37,7 +37,7 @@ public:
private:
cAbstractMedia *media;
-};
+ };
#endif /* HTTPMEDIARESPONSE_H */
diff --git a/cmps/serverlib/serverlib.layout b/cmps/serverlib/serverlib.layout
index cff8ff9..10f38d5 100644
--- a/cmps/serverlib/serverlib.layout
+++ b/cmps/serverlib/serverlib.layout
@@ -11,12 +11,12 @@
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
- <File name="src/MediaListHandler.cc" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+ <File name="src/HTMLListAssembler.cc" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
- <File name="src/HTMLListAssembler.cc" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+ <File name="src/MediaListHandler.cc" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
diff --git a/cmps/serverlib/serverlib.layout.save b/cmps/serverlib/serverlib.layout.save
index cff8ff9..c8e0376 100644
--- a/cmps/serverlib/serverlib.layout.save
+++ b/cmps/serverlib/serverlib.layout.save
@@ -1,11 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
<ActiveTarget name="Debug" />
- <File name="src/JSonListAssembler.cc" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
- <Cursor>
- <Cursor1 position="1183" topLine="0" />
- </Cursor>
- </File>
<File name="src/AbstractMediaRequestHandler.cc" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
@@ -21,4 +16,9 @@
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
+ <File name="src/JSonListAssembler.cc" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+ <Cursor>
+ <Cursor1 position="1183" topLine="0" />
+ </Cursor>
+ </File>
</CodeBlocks_layout_file>
diff --git a/cmps/serverlib/src/HTMLListAssembler.cc b/cmps/serverlib/src/HTMLListAssembler.cc
index c455fc1..bf190fe 100644
--- a/cmps/serverlib/src/HTMLListAssembler.cc
+++ b/cmps/serverlib/src/HTMLListAssembler.cc
@@ -1,25 +1,25 @@
/**
* ======================== legal notice ======================
- *
+ *
* File: HTMLListAssembler.cc
* Created: 6. Juli 2012, 09
* Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
* Project: cmps - the backend (server) part of compound media player
- *
+ *
* CMP - compound media player
- *
+ *
* is a client/server mediaplayer intended to play any media from any workstation
* without the need to export or mount shares. cmps is an easy to use backend
* with a (ready to use) HTML-interface. Additionally the backend supports
* authentication via HTTP-digest authorization.
* cmpc is a client with vdr-like osd-menues.
- *
+ *
* Copyright (c) 2012 Reinhard Mantey, some rights reserved!
* published under Creative Commons by-sa
* For details see http://creativecommons.org/licenses/by-sa/3.0/
- *
+ *
* The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp
- *
+ *
* --------------------------------------------------------------
*/
#include <HTMLListAssembler.h>
@@ -98,27 +98,25 @@ cStringBuilder &cHTMLListAssembler::genDelim(cStringBuilder &sb)
cStringBuilder &cHTMLListAssembler::genMediaLink(cStringBuilder &sb, void *Element, bool odd)
{
cAbstractMedia *m = (cAbstractMedia *)Element;
- cUrl *uri = new cUrl(m->LogicalPath());
- char *lp = uri->ToString();
-
- sb.Append("<a class=\"");
- sb.Append(odd ? "odd" : "even");
- sb.Append("\" href=\"");
- sb.Append(lp);
- free(lp);
- sb.Append("\">");
- switch (m->MediaType()) {
- case cAbstractMedia::Audio: sb.Append("[A] "); break;
- case cAbstractMedia::Movie: sb.Append("[M] "); break;
- case cAbstractMedia::DVDImage: sb.Append("[D] "); break;
- case cAbstractMedia::LegacyVdrRecording: sb.Append("[L] "); break;
- case cAbstractMedia::VdrRecording: sb.Append("[V] "); break;
- case cAbstractMedia::Picture: sb.Append("[P] "); break;
- default: ;
- }
- sb.Append(m->Name());
- sb.Append("</a>");
+ if (m) {
+ sb.Append("<a class=\"");
+ sb.Append(odd ? "odd" : "even");
+ sb.Append("\" href=\"");
+ sb.Append(m->URI());
+ sb.Append("\">");
+ switch (m->MediaType()) {
+ case cAbstractMedia::Audio: sb.Append("[A] "); break;
+ case cAbstractMedia::Movie: sb.Append("[M] "); break;
+ case cAbstractMedia::DVDImage: sb.Append("[D] "); break;
+ case cAbstractMedia::LegacyVdrRecording: sb.Append("[L] "); break;
+ case cAbstractMedia::VdrRecording: sb.Append("[V] "); break;
+ case cAbstractMedia::Picture: sb.Append("[P] "); break;
+ default: ;
+ }
+ sb.Append(m->Name());
+ sb.Append("</a>");
+ }
return sb;
}
diff --git a/cmps/serverlib/src/JSonListAssembler.cc b/cmps/serverlib/src/JSonListAssembler.cc
index f49b8ec..05ff5cc 100644
--- a/cmps/serverlib/src/JSonListAssembler.cc
+++ b/cmps/serverlib/src/JSonListAssembler.cc
@@ -1,25 +1,25 @@
/**
* ======================== legal notice ======================
- *
+ *
* File: JSonListAssembler.cc
* Created: 6. Juli 2012, 09
* Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
* Project: cmps - the backend (server) part of compound media player
- *
+ *
* CMP - compound media player
- *
+ *
* is a client/server mediaplayer intended to play any media from any workstation
* without the need to export or mount shares. cmps is an easy to use backend
* with a (ready to use) HTML-interface. Additionally the backend supports
* authentication via HTTP-digest authorization.
* cmpc is a client with vdr-like osd-menues.
- *
+ *
* Copyright (c) 2012 Reinhard Mantey, some rights reserved!
* published under Creative Commons by-sa
* For details see http://creativecommons.org/licenses/by-sa/3.0/
- *
+ *
* The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp
- *
+ *
* --------------------------------------------------------------
*/
#include <JSonListAssembler.h>
@@ -28,6 +28,7 @@
#include <Url.h>
cJSonListAssembler::cJSonListAssembler()
+ : writer(NULL)
{
}
@@ -58,17 +59,17 @@ bool cJSonListAssembler::OpenList(cStringBuilder &sb, std::map<int, size_t> &Cat
bool cJSonListAssembler::AddElement(cStringBuilder &sb, void *ListElement, bool odd)
{
cAbstractMedia *m = (cAbstractMedia *)ListElement;
- cUrl *uri = new cUrl(m->LogicalPath());
- char *lp = uri->ToString();
- writer->Object();
- writer->Key("name").Value(m->Name());
- writer->Key("type").Value(m->MediaType());
- writer->Key("path").Value(lp);
- free(lp);
- writer->EndObject();
+ if (m) {
+ writer->Object();
+ writer->Key("name").Value(m->Name());
+ writer->Key("type").Value(m->MediaType());
+ writer->Key("path").Value(m->URI());
+ writer->EndObject();
- return true;
+ return true;
+ }
+ return false;
}
bool cJSonListAssembler::CloseList(cStringBuilder &sb, size_t total, size_t start, uint delta)
diff --git a/cmps/serverlib/src/MediaFileHandler.cc b/cmps/serverlib/src/MediaFileHandler.cc
index b2e97a3..200c933 100644
--- a/cmps/serverlib/src/MediaFileHandler.cc
+++ b/cmps/serverlib/src/MediaFileHandler.cc
@@ -1,25 +1,25 @@
/**
* ======================== legal notice ======================
- *
+ *
* File: MediaFileHandler.cc
* Created: 5. Juli 2012, 08
* Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
* Project: cmps - the backend (server) part of compound media player
- *
+ *
* CMP - compound media player
- *
+ *
* is a client/server mediaplayer intended to play any media from any workstation
* without the need to export or mount shares. cmps is an easy to use backend
* with a (ready to use) HTML-interface. Additionally the backend supports
* authentication via HTTP-digest authorization.
* cmpc is a client with vdr-like osd-menues.
- *
+ *
* Copyright (c) 2012 Reinhard Mantey, some rights reserved!
* published under Creative Commons by-sa
* For details see http://creativecommons.org/licenses/by-sa/3.0/
- *
+ *
* The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp
- *
+ *
* --------------------------------------------------------------
*/
#include <MediaFileHandler.h>
@@ -40,6 +40,8 @@ cMediaFileHandler::~cMediaFileHandler()
cHTTPResponse *cMediaFileHandler::ProcessRequest(cHTTPRequest& Request)
{
+ isyslog("have to find requested media: >%s<", Request.Url().Path());
+
cAbstractMedia *media = FileSystemScanner()->FindMedia(Request.Url().Path());
isyslog("cMediaFileHandler::ProcessRequest ... %0X", media);
diff --git a/cmps/tests/FScanTest.cc b/cmps/tests/FScanTest.cc
index 2684557..3a60bfb 100644
--- a/cmps/tests/FScanTest.cc
+++ b/cmps/tests/FScanTest.cc
@@ -1,25 +1,25 @@
/**
* ======================== legal notice ======================
- *
+ *
* File: FScanTest.cc
* Created: 02.07.2012, 16
* Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
* Project: cmps - the backend (server) part of compound media player
- *
+ *
* CMP - compound media player
- *
+ *
* is a client/server mediaplayer intended to play any media from any workstation
* without the need to export or mount shares. cmps is an easy to use backend
* with a (ready to use) HTML-interface. Additionally the backend supports
* authentication via HTTP-digest authorization.
* cmpc is a client with vdr-like osd-menues.
- *
+ *
* Copyright (c) 2012 Reinhard Mantey, some rights reserved!
* published under Creative Commons by-sa
* For details see http://creativecommons.org/licenses/by-sa/3.0/
- *
+ *
* The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp
- *
+ *
* --------------------------------------------------------------
*/
#include <stdlib.h>
@@ -86,7 +86,7 @@ void FScanTest::test4()
for (size_t i=0; i < scanner.MediaPool().size(); ++i) {
media = (cAbstractMedia *) scanner.MediaPool()[i];
- std::cout << media->Name() << " [" << media->MimeType() << "] => " << media->LogicalPath() << std::endl;
+ std::cout << media->Name() << " [" << media->MimeType() << "] => " << media->AbsolutePath() << std::endl;
}
std::cout << std::endl << "found " << scanner.MediaPool().size() << " media, in " << end - start << " ms." << std::endl;
@@ -98,6 +98,7 @@ void FScanTest::test4()
end = cTimeMs::Now();
std::cout << "array search took " << end - start << " ms." << std::endl;
+ cFile::Cleanup();
}
int main(int argc, char** argv)
diff --git a/cmps/tests/FileSystemTest.cc b/cmps/tests/FileSystemTest.cc
index 99a76d0..42a7836 100644
--- a/cmps/tests/FileSystemTest.cc
+++ b/cmps/tests/FileSystemTest.cc
@@ -1,77 +1,205 @@
-/**
- * ======================== legal notice ======================
- *
- * File: FileSystemTest.cc
- * Created: 21.07.2012, 12:40:48
- * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
- * Project: cmps - the backend (server) part of compound media player
- *
- * CMP - compound media player
- *
- * is a client/server mediaplayer intended to play any media from any workstation
- * without the need to export or mount shares. cmps is an easy to use backend
- * with a (ready to use) HTML-interface. Additionally the backend supports
- * authentication via HTTP-digest authorization.
- * cmpc is a client with vdr-like osd-menues.
- *
- * Copyright (c) 2012 Reinhard Mantey, some rights reserved!
- * published under Creative Commons by-sa
- * For details see http://creativecommons.org/licenses/by-sa/3.0/
- *
- * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp
- *
- * --------------------------------------------------------------
+/*
+ * File: FileSystemTest.cc
+ * Author: django
+ *
+ * Created on 21.07.2012, 12:40:48
*/
+
#include <stdlib.h>
#include <iostream>
#include <FileSystem.h>
#include <File.h>
+#include <StringBuilder.h>
+#include <LegacyVdrRecording.h>
+#include <VdrRecording.h>
+#include <DVDImage.h>
+#include <Audio.h>
+#include <Picture.h>
+#include <Logging.h>
+#include <TimeMs.h>
+#include <string.h>
-/*
- * Simple C++ Test Suite
- */
+int visitor(void *opaque, cFile *Parent, const char *Name)
+{
+ cFile *child = new cFile(*Parent, Name);
+
+ std::cout << Parent->Name() << " - has child-entry: " << Name << std::endl;
+ if (child->IsDirectory()) {
+ child->VisitFiles(visitor, opaque);
+ }
+ char *uri = child->toURI();
+ const char *path = child->AbsolutePath();
+
+ std::cout << "child does ";
+ if (!child->Exists()) std::cout << "NOT ";
+ std::cout << "exists ..." << std::endl;
+ std::cout << path << " - has URI: " << uri << std::endl << std::endl;
+ free(uri);
+ delete child;
+
+ return 0;
+}
void test1()
{
std::cout << "FileSystemTest test 1" << std::endl;
cFile *f = new cFile("/media/xchange/");
+ const char *path = f->AbsolutePath();
- std::cout << "got file: " << f->AbsolutePath() << std::endl;
-
+ std::cout << "got file: " << path << std::endl;
cFile *other = f->Parent();
- std::cout << "parent is file: " << other->AbsolutePath() << std::endl;
+ other->SetVirtualRoot(true);
+ path = other->AbsolutePath();
+ std::cout << "parent is file: " << path << std::endl;
cFile *newOne = new cFile(*other, "/video/test/blah");
- std::cout << "assembled file: " << newOne->AbsolutePath() << std::endl;
+ path = newOne->AbsolutePath();
+ std::cout << "assembled file: " << path << std::endl;
+
+ cFile *again = new cFile("/media/audio/Collection/Rock/Idol, Billy");
+
+ path = again->AbsolutePath();
+ std::cout << "re-assembled file: " << path << std::endl;
+
+ std::cout << path << " does ";
+ if (!again->Exists()) std::cout << "NOT ";
+ std::cout << "exists" << std::endl;
+
+ again->VisitFiles(visitor, NULL);
delete newOne;
delete other;
delete f;
+ delete again;
+
+ cFile::Cleanup();
+}
+
+int check4Media(void *opaque, cFile *Parent, const char *Name)
+{
+ if (!opaque) return -1;
+ std::vector<cAbstractMedia *> *pool = (std::vector<cAbstractMedia *> *) opaque;
+ cFile *curFile = new cFile(*Parent, Name);
+ const char *mimeType = NULL;
+ cAbstractMedia *rv = NULL;
+
+ if (!curFile) {
+ esyslog("ERROR: out of memory!");
+ return -1;
+ }
+ if (!curFile->Exists()) {
+ delete curFile;
+ return -1;
+ }
+ if (curFile->IsDirectory()) {
+ static const char *keyFiles[] = { "001.vdr", "00001.ts", "VIDEO_TS/VIDEO_TS.IFO", NULL };
+ cFile *tmp;
+ const char *check;
+ int n=0;
+
+ for (const char **kf = keyFiles; kf && *kf; ++kf, ++n) {
+ tmp = new cFile(*curFile, *kf);
+ check = tmp ? tmp->AbsolutePath() : NULL;
+
+ if (tmp->Exists() && tmp->IsFile() && !tmp->IsDirectory()) {
+ switch (n) {
+ case 0: rv = new cLegacyVdrRecording(*curFile); break;
+ case 1: rv = new cVdrRecording(*curFile); break;
+ default: rv = new cDVDImage(*curFile); break;
+ }
+ }
+ delete tmp;
+ }
+ if (!rv) curFile->VisitFiles(check4Media, opaque);
+ }
+ else {
+ const char *extension = strrchr(Name, '.');
+
+ if (!extension) {
+ delete curFile;
+
+ return -1;
+ }
+ ++extension;
+ mimeType = cMovie::ContentType(extension);
+ if (mimeType) rv = new cMovie(*curFile, mimeType);
+ else {
+ mimeType = cAudio::ContentType(extension);
+ if (mimeType) rv = new cAudio(*curFile, mimeType);
+ else {
+ mimeType = cPicture::ContentType(extension);
+ if (mimeType) rv = new cPicture(*curFile, mimeType);
+ }
+ }
+ }
+ delete curFile;
+ if (rv) {
+ pool->push_back(rv);
+ return 0;
+ }
+ else return -1;
}
void test2()
{
std::cout << "FileSystemTest test 2" << std::endl;
- std::cout << "%TEST_FAILED% time=0 testname=test2 (FileSystemTest) message=error message sample" << std::endl;
+ cFile mediaRoot("/media");
+ cFile &startScan = mediaRoot; //("/media/images");
+
+ if (!mediaRoot.Exists() || !mediaRoot.IsDirectory())
+ std::cout << "%TEST_FAILED% time=0 testname=test2 (FileSystemTest) message=error message sample" << std::endl;
+ if (!startScan.Exists() || !startScan.IsDirectory())
+ std::cout << "%TEST_FAILED% time=0 testname=test2 (FileSystemTest) message=error message sample" << std::endl;
+
+ mediaRoot.SetVirtualRoot();
+ std::vector<cAbstractMedia *> mediaPool;
+
+ uint64_t start = cTimeMs::Now();
+ startScan.VisitFiles(check4Media, &mediaPool);
+ uint64_t end = cTimeMs::Now();
+
+ for (size_t i=0; i < mediaPool.size(); ++i) {
+ std::cout << "pool entry: " << mediaPool[i]->Name() << std::endl;
+ }
+ //19: got 9998 media in 8081ms. (with valgrind)
+ // ==9779== total heap usage: 637,920 allocs, 637,918 frees, 172,023,271 bytes allocated
+ //19: got 9998 media in 3750ms. (with valgrind)
+ //19: got 9998 media in 122ms. (without valgrind)
+ // ==30004== total heap usage: 348,984 allocs, 348,982 frees, 103,182,434 bytes allocated
+ //01: got 5739 media in 88165ms. (with valgrind)
+ // ==2605== total heap usage: 924,253 allocs, 924,247 frees, 259,567,759 bytes allocated
+ //01: got 5739 media in 71959ms. (with valgrind)
+ //01: got 5739 media in 54619ms. (without valgrind - fresh reboot)
+ //01: got 5739 media in 205ms (without valgrind - repeated run)
+ // ==2465== total heap usage: 469,151 allocs, 469,145 frees, 155,163,997 bytes allocated
+ std::cout << "got " << mediaPool.size() << " media in " << (end - start) << "ms." << std::endl;
+ for (size_t i=0; i < mediaPool.size(); ++i) {
+ delete mediaPool[i];
+ }
+ cFile::Cleanup();
}
int main(int argc, char** argv)
{
+ uint64_t t0 = cTimeMs::Now();
std::cout << "%SUITE_STARTING% FileSystemTest" << std::endl;
std::cout << "%SUITE_STARTED%" << std::endl;
std::cout << "%TEST_STARTED% test1 (FileSystemTest)" << std::endl;
+ uint64_t start = cTimeMs::Now();
test1();
- std::cout << "%TEST_FINISHED% time=0 test1 (FileSystemTest)" << std::endl;
+ uint64_t end = cTimeMs::Now();
+ std::cout << "%TEST_FINISHED% time=" << (double)(end - start) / 1000 << " test1 (FileSystemTest)" << std::endl;
std::cout << "%TEST_STARTED% test2 (FileSystemTest)\n" << std::endl;
+ start = cTimeMs::Now();
test2();
- std::cout << "%TEST_FINISHED% time=0 test2 (FileSystemTest)" << std::endl;
+ end = cTimeMs::Now();
+ std::cout << "%TEST_FINISHED% time=" << (double)(end - start) / 1000 << " test2 (FileSystemTest)" << std::endl;
- std::cout << "%SUITE_FINISHED% time=0" << std::endl;
+ std::cout << "%SUITE_FINISHED% time=" << (double)(cTimeMs::Now() - t0) / 1000 << std::endl;
return (EXIT_SUCCESS);
}
-