diff options
Diffstat (limited to 'libs/IO/include')
-rw-r--r-- | libs/IO/include/ConfigReader.h | 48 | ||||
-rw-r--r-- | libs/IO/include/File.h | 67 | ||||
-rw-r--r-- | libs/IO/include/FileReader.h | 44 | ||||
-rw-r--r-- | libs/IO/include/FileRepresentation.h | 56 | ||||
-rw-r--r-- | libs/IO/include/FileSystem.h | 52 | ||||
-rw-r--r-- | libs/IO/include/LineReader.h | 48 |
6 files changed, 315 insertions, 0 deletions
diff --git a/libs/IO/include/ConfigReader.h b/libs/IO/include/ConfigReader.h new file mode 100644 index 0000000..f3aa5eb --- /dev/null +++ b/libs/IO/include/ConfigReader.h @@ -0,0 +1,48 @@ +/** + * ======================== legal notice ====================== + * + * File: ConfigReader.h + * Created: 28. Juli 2012, 18:41 + * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a> + * Project: libIO: classes for files, filesystem and input/output + * + * 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 CONFIGREADER_H +#define CONFIGREADER_H + +#include <tuple> +#include <string> + +class cLineReader; +class cConfigReader +{ +public: + typedef std::tuple <std::string, std::string> ConfigEntry; + + cConfigReader(cLineReader *LineReader); + virtual ~cConfigReader(); + + void Close(void); + ConfigEntry *ReadValue(void); + +private: + cLineReader *reader; + }; + +#endif /* CONFIGREADER_H */ + diff --git a/libs/IO/include/File.h b/libs/IO/include/File.h new file mode 100644 index 0000000..b531bfc --- /dev/null +++ b/libs/IO/include/File.h @@ -0,0 +1,67 @@ +/** + * ======================== legal notice ====================== + * + * File: File.h + * Created: 21. Juli 2012, 12 + * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a> + * Project: libIO: classes for files, filesystem and input/output + * + * 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 FILE_H +#define FILE_H + +#include <stddef.h> +#include <sys/types.h> + +class cFileSystem; +class cFileRepresentation; +class cStringBuilder; +class cFile { +public: + cFile(const char *Path = NULL); + cFile(const cFile &other); + cFile(const cFile &Parent, const char *RelativePath); + virtual ~cFile(); + + cFile &operator =(const cFile &other); + bool CanRead(void) const; + bool CanWrite(void) const; + bool CanExecute(void) const; + bool Exists(void) const; + bool IsDirectory(void) const; + bool IsFile(void) const; + bool IsSymbolic(void) const; + off64_t Size(void) const; + ulong LastModified(void) const; + const char *Name(void) const; + void SetVirtualRoot(bool isRoot = true); + const char *AbsolutePath(void) const; ///< returns an allocated string + char *toURI(void) const; ///< returns an allocated string + cFile *Parent(void) const; ///< allocates a new file instance! + void VisitFiles(int (*cb)(void *, cFile *, const char *), void *opaque); + static void Cleanup(void); + +private: + cFile(const cFileRepresentation *); + const cFileRepresentation *rep; + static cFileSystem *fs; + friend class cFileSystem; + }; + +#endif /* FILE_H */ + diff --git a/libs/IO/include/FileReader.h b/libs/IO/include/FileReader.h new file mode 100644 index 0000000..31cb7d6 --- /dev/null +++ b/libs/IO/include/FileReader.h @@ -0,0 +1,44 @@ +/** + * ======================== legal notice ====================== + * + * File: FileReader.h + * Created: 28. Juli 2012, 15:00 + * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a> + * Project: libIO: classes for files, filesystem and input/output + * + * 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 FILEREADER_H +#define FILEREADER_H + +class cFile; +class cFileReader +{ +public: + cFileReader(cFile *Input); + virtual ~cFileReader(); + + int Read(char *buf, int bufSize); + void Close(); + +private: + int fd; + cFile *file; + }; + +#endif /* FILEREADER_H */ + diff --git a/libs/IO/include/FileRepresentation.h b/libs/IO/include/FileRepresentation.h new file mode 100644 index 0000000..2c2db5a --- /dev/null +++ b/libs/IO/include/FileRepresentation.h @@ -0,0 +1,56 @@ +/** + * ======================== legal notice ====================== + * + * File: FileRepresentation.h + * Created: 21. Juli 2012, 12 + * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a> + * Project: libIO: classes for files, filesystem and input/output + * + * 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 FILEREPRESENTATION_H +#define FILEREPRESENTATION_H + +#include <sys/types.h> + +class cStringBuilder; +class cFileRepresentation { +public: + virtual ~cFileRepresentation(); + + const char *Path(void) const; + const cFileRepresentation *getParent(void) const { return parent; }; + void SetVirtualRoot(bool isRoot); + +private: + cFileRepresentation(const char *Name); + cFileRepresentation(const cFileRepresentation *Parent, const char *Name); + char *toURI(void) const; + bool exists; + bool isRoot; + bool isVirtualRoot; + mode_t mode; + off64_t size; + ulong lastModified; + char *name; + mutable char *path; + const cFileRepresentation *parent; + friend class cFileSystem; + friend class cFile; + }; + +#endif // FILEREPRESENTATION_H diff --git a/libs/IO/include/FileSystem.h b/libs/IO/include/FileSystem.h new file mode 100644 index 0000000..cd085db --- /dev/null +++ b/libs/IO/include/FileSystem.h @@ -0,0 +1,52 @@ +/** + * ======================== legal notice ====================== + * + * File: FileSystem.h + * Created: 21. Juli 2012, 12 + * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a> + * Project: libIO: classes for files, filesystem and input/output + * + * 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 FILESYSTEM_H +#define FILESYSTEM_H + +#include <tr1/unordered_map> +#include <string> + +class cFile; +class cFileRepresentation; +class cFileSystem { +public: + cFileSystem(); + virtual ~cFileSystem(); + + cFileRepresentation *representationOfFile(const char *Path); + cFileRepresentation *representationOfFile(const cFile &Parent, const char *Path); + +private: + cFileRepresentation *cacheEntry(const char *Path); + cFileRepresentation *representationOfFile(const cFileRepresentation *parentRep, const char* Path); + std::tr1::unordered_map<std::string, cFileRepresentation *> fileCache; + static char PathSeparator; + static char RootPath[4]; + friend class cFileRepresentation; + friend class cFile; + }; + +#endif /* FILESYSTEM_H */ + diff --git a/libs/IO/include/LineReader.h b/libs/IO/include/LineReader.h new file mode 100644 index 0000000..8b8b754 --- /dev/null +++ b/libs/IO/include/LineReader.h @@ -0,0 +1,48 @@ +/** + * ======================== legal notice ====================== + * + * File: LineReader.h + * Created: 28. Juli 2012, 06 + * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a> + * Project: libIO: classes for files, filesystem and input/output + * + * 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 LINEREADER_H +#define LINEREADER_H + + +class cFileReader; +class cLineReader +{ +public: + cLineReader(cFileReader *FileReader); + virtual ~cLineReader(); + + const char *ReadLine(void); + void Close(void); + +private: + cFileReader *reader; + int bytesRead; + int off; + int bufSize; + char *buf; + char *lastLine; + }; + +#endif // LINEREADER_H |