diff options
author | geronimo <geronimo013@gmx.de> | 2012-07-29 15:11:47 +0200 |
---|---|---|
committer | geronimo <geronimo013@gmx.de> | 2012-07-29 15:11:47 +0200 |
commit | 85cb3f04252b0228830903b21c08bb64e9919c18 (patch) | |
tree | 5c00dbd8d296861aa56cca598ee2a36e51971822 /libs/fsScan/src/FileRepresentation.cc | |
parent | 736033f3d532c4814eeff84db5dbf99f0249df6e (diff) | |
download | cmp-85cb3f04252b0228830903b21c08bb64e9919c18.tar.gz cmp-85cb3f04252b0228830903b21c08bb64e9919c18.tar.bz2 |
changed server setup to config file, little rearrangement of sources
Diffstat (limited to 'libs/fsScan/src/FileRepresentation.cc')
-rw-r--r-- | libs/fsScan/src/FileRepresentation.cc | 132 |
1 files changed, 0 insertions, 132 deletions
diff --git a/libs/fsScan/src/FileRepresentation.cc b/libs/fsScan/src/FileRepresentation.cc deleted file mode 100644 index 81599a3..0000000 --- a/libs/fsScan/src/FileRepresentation.cc +++ /dev/null @@ -1,132 +0,0 @@ -/** - * ======================== legal notice ====================== - * - * File: FileRepresentation.cc - * Created: 21. Juli 2012, 12 - * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a> - * Project: libfsScan: mediatypes and filesystem scanning - * - * 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 <FileRepresentation.h> -#include <FileSystem.h> -#include <StringBuilder.h> -#include <Url.h> -#include <Codec.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <string.h> -#include <stdlib.h> -#include <iostream> -#include <stack> - -cFileRepresentation::cFileRepresentation(const char *Name) - : exists(false) - , isRoot(true) - , isVirtualRoot(true) - , mode(0) - , size(0) - , lastModified(0) - , name(NULL) - , path(NULL) - , parent(NULL) -{ - struct stat st; - - if (!stat(Name, &st)) { - name = strdup(Name); - exists = true; - mode = st.st_mode; - size = st.st_size; - lastModified = st.st_mtime; - } -} - -cFileRepresentation::cFileRepresentation(const cFileRepresentation *Parent, const char *Name) - : exists(false) - , isRoot(false) - , isVirtualRoot(false) - , mode(0) - , size(0) - , lastModified(0) - , name(strdup(Name)) - , path(NULL) - , parent(Parent) -{ - struct stat st; - - if (!stat(Path(), &st)) { - exists = true; - mode = st.st_mode; - size = st.st_size; - lastModified = st.st_mtime; - } -} - -cFileRepresentation::~cFileRepresentation() -{ - free(name); - free(path); -} - -const char *cFileRepresentation::Path() const -{ - if (!path) { - cStringBuilder sb; - - if (parent) sb.Append(parent->Path()); - sb.Append(cFileSystem::PathSeparator).Append(name); - path = sb.toString(); - } - return path; -} - -void cFileRepresentation::SetVirtualRoot(bool isRoot) -{ - isVirtualRoot = isRoot; -} - -char *cFileRepresentation::toURI() const -{ - cStringBuilder *sb = new cStringBuilder(); - const cFileRepresentation *f = this; - std::stack<const cFileRepresentation *> rev; - cURLEncoder *enc = cUrl::Encoder(); - char *tmp, *chk, *rv; - size_t stackSize; - - while (!f->isVirtualRoot) { - rev.push(f); - stackSize = rev.size(); - f = f->parent; - } - - for (;;) { - f = rev.top(); - rev.pop(); - chk = f->name + strlen(f->name) - 1; - if (*chk != cFileSystem::PathSeparator) sb->Append(cFileSystem::PathSeparator); - tmp = enc->Encode(f->name); - sb->Append(tmp); - free(tmp); - if (rev.empty()) break; - } - rv = sb->toString(); - delete sb; - - return rv; -} |