diff options
Diffstat (limited to 'libs/IO')
-rw-r--r-- | libs/IO/IO.cbp | 4 | ||||
-rw-r--r-- | libs/IO/IO.layout | 20 | ||||
-rw-r--r-- | libs/IO/include/CommandReader.h | 49 | ||||
-rw-r--r-- | libs/IO/include/ConfigReader.h | 3 | ||||
-rw-r--r-- | libs/IO/include/FileReader.h | 11 | ||||
-rw-r--r-- | libs/IO/include/FileRepresentation.h | 12 | ||||
-rw-r--r-- | libs/IO/include/LineReader.h | 10 | ||||
-rw-r--r-- | libs/IO/include/Reader.h | 41 | ||||
-rw-r--r-- | libs/IO/nbproject/Makefile-Debug.mk | 12 | ||||
-rw-r--r-- | libs/IO/nbproject/Makefile-Release.mk | 12 | ||||
-rw-r--r-- | libs/IO/nbproject/configurations.xml | 4 | ||||
-rw-r--r-- | libs/IO/src/CommandReader.cc | 120 | ||||
-rw-r--r-- | libs/IO/src/File.cc | 12 | ||||
-rw-r--r-- | libs/IO/src/FileReader.cc | 18 | ||||
-rw-r--r-- | libs/IO/src/FileRepresentation.cc | 12 | ||||
-rw-r--r-- | libs/IO/src/LineReader.cc | 4 | ||||
-rw-r--r-- | libs/IO/src/Reader.cc | 44 |
17 files changed, 335 insertions, 53 deletions
diff --git a/libs/IO/IO.cbp b/libs/IO/IO.cbp index 36f087a..e1377fc 100644 --- a/libs/IO/IO.cbp +++ b/libs/IO/IO.cbp @@ -48,18 +48,22 @@ <Add directory="../util/include" /> <Add directory="../vdr/include" /> </Compiler> + <Unit filename="include/CommandReader.h" /> <Unit filename="include/ConfigReader.h" /> <Unit filename="include/File.h" /> <Unit filename="include/FileReader.h" /> <Unit filename="include/FileRepresentation.h" /> <Unit filename="include/FileSystem.h" /> <Unit filename="include/LineReader.h" /> + <Unit filename="include/Reader.h" /> + <Unit filename="src/CommandReader.cc" /> <Unit filename="src/ConfigReader.cc" /> <Unit filename="src/File.cc" /> <Unit filename="src/FileReader.cc" /> <Unit filename="src/FileRepresentation.cc" /> <Unit filename="src/FileSystem.cc" /> <Unit filename="src/LineReader.cc" /> + <Unit filename="src/Reader.cc" /> <Extensions> <code_completion /> <envvars /> diff --git a/libs/IO/IO.layout b/libs/IO/IO.layout index 0e6cd97..4af9097 100644 --- a/libs/IO/IO.layout +++ b/libs/IO/IO.layout @@ -1,24 +1,24 @@ <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <CodeBlocks_layout_file> <ActiveTarget name="Debug" /> - <File name="src/File.cc" open="1" top="1" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> + <File name="src/FileReader.cc" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> <Cursor> - <Cursor1 position="1130" topLine="0" /> + <Cursor1 position="737" topLine="0" /> </Cursor> </File> - <File name="include/File.h" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> + <File name="src/ConfigReader.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" /> + <Cursor1 position="459" topLine="0" /> </Cursor> </File> - <File name="include/ConfigReader.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> + <File name="src/File.cc" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> <Cursor> - <Cursor1 position="475" topLine="0" /> + <Cursor1 position="1130" topLine="0" /> </Cursor> </File> - <File name="src/FileReader.cc" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> + <File name="include/ConfigReader.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> <Cursor> - <Cursor1 position="1320" topLine="0" /> + <Cursor1 position="475" topLine="0" /> </Cursor> </File> <File name="src/FileRepresentation.cc" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> @@ -31,9 +31,9 @@ <Cursor1 position="854" topLine="0" /> </Cursor> </File> - <File name="src/ConfigReader.cc" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> + <File name="include/File.h" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> <Cursor> - <Cursor1 position="459" topLine="0" /> + <Cursor1 position="0" topLine="0" /> </Cursor> </File> </CodeBlocks_layout_file> diff --git a/libs/IO/include/CommandReader.h b/libs/IO/include/CommandReader.h new file mode 100644 index 0000000..e54a64c --- /dev/null +++ b/libs/IO/include/CommandReader.h @@ -0,0 +1,49 @@ +/** + * ======================== legal notice ====================== + * + * File: CommandReader.h + * Created: 30. Juli 2012, 06:42 + * 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 COMMANDREADER_H +#define COMMANDREADER_H + +#include <Reader.h> +#include <vector> +#include <string> + +class cCommandReader : public cReader { +public: + cCommandReader(const char *cmd); + virtual ~cCommandReader(); + + void AddCommandParameter(const char *Param); + +protected: + virtual bool Open(void); + virtual void Close(void); + +private: + pid_t pid; + std::vector<std::string> args; + }; + +#endif /* COMMANDREADER_H */ + diff --git a/libs/IO/include/ConfigReader.h b/libs/IO/include/ConfigReader.h index f3aa5eb..6d0cd30 100644 --- a/libs/IO/include/ConfigReader.h +++ b/libs/IO/include/ConfigReader.h @@ -29,8 +29,7 @@ #include <string> class cLineReader; -class cConfigReader -{ +class cConfigReader { public: typedef std::tuple <std::string, std::string> ConfigEntry; diff --git a/libs/IO/include/FileReader.h b/libs/IO/include/FileReader.h index 31cb7d6..816b140 100644 --- a/libs/IO/include/FileReader.h +++ b/libs/IO/include/FileReader.h @@ -25,18 +25,19 @@ #ifndef FILEREADER_H #define FILEREADER_H +#include <Reader.h> + class cFile; -class cFileReader -{ +class cFileReader : public cReader { public: cFileReader(cFile *Input); virtual ~cFileReader(); - int Read(char *buf, int bufSize); - void Close(); +protected: + virtual bool Open(void); + virtual void Close(void); private: - int fd; cFile *file; }; diff --git a/libs/IO/include/FileRepresentation.h b/libs/IO/include/FileRepresentation.h index 8bc9d9b..2c2db5a 100644 --- a/libs/IO/include/FileRepresentation.h +++ b/libs/IO/include/FileRepresentation.h @@ -1,25 +1,25 @@ /** * ======================== 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 diff --git a/libs/IO/include/LineReader.h b/libs/IO/include/LineReader.h index 8b8b754..3de64dc 100644 --- a/libs/IO/include/LineReader.h +++ b/libs/IO/include/LineReader.h @@ -25,19 +25,17 @@ #ifndef LINEREADER_H #define LINEREADER_H - -class cFileReader; -class cLineReader -{ +class cReader; +class cLineReader { public: - cLineReader(cFileReader *FileReader); + cLineReader(cReader *Reader); virtual ~cLineReader(); const char *ReadLine(void); void Close(void); private: - cFileReader *reader; + cReader *reader; int bytesRead; int off; int bufSize; diff --git a/libs/IO/include/Reader.h b/libs/IO/include/Reader.h new file mode 100644 index 0000000..bc346a6 --- /dev/null +++ b/libs/IO/include/Reader.h @@ -0,0 +1,41 @@ +/** + * ======================== legal notice ====================== + * + * File: Reader.h + * Created: 30. Juli 2012, 06:44 + * 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 READER_H +#define READER_H + +class cReader { +public: + cReader(); + virtual ~cReader(); + virtual int Read(char *buf, int bufSize); + +protected: + virtual bool Open(void) = 0; + virtual void Close(void) = 0; + int fd; + }; + +#endif /* READER_H */ + diff --git a/libs/IO/nbproject/Makefile-Debug.mk b/libs/IO/nbproject/Makefile-Debug.mk index 0fa73d7..36615b9 100644 --- a/libs/IO/nbproject/Makefile-Debug.mk +++ b/libs/IO/nbproject/Makefile-Debug.mk @@ -35,9 +35,11 @@ OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM} # Object Files OBJECTFILES= \ + ${OBJECTDIR}/src/CommandReader.o \ ${OBJECTDIR}/src/FileRepresentation.o \ ${OBJECTDIR}/src/LineReader.o \ ${OBJECTDIR}/src/File.o \ + ${OBJECTDIR}/src/Reader.o \ ${OBJECTDIR}/src/ConfigReader.o \ ${OBJECTDIR}/src/FileReader.o \ ${OBJECTDIR}/src/FileSystem.o @@ -69,6 +71,11 @@ ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libio.a: ${OBJECTFILES} ${AR} -rv ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libio.a ${OBJECTFILES} $(RANLIB) ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libio.a +${OBJECTDIR}/src/CommandReader.o: src/CommandReader.cc + ${MKDIR} -p ${OBJECTDIR}/src + ${RM} $@.d + $(COMPILE.cc) -g -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE=1 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_REENTRANT -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iinclude -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/CommandReader.o src/CommandReader.cc + ${OBJECTDIR}/src/FileRepresentation.o: src/FileRepresentation.cc ${MKDIR} -p ${OBJECTDIR}/src ${RM} $@.d @@ -84,6 +91,11 @@ ${OBJECTDIR}/src/File.o: src/File.cc ${RM} $@.d $(COMPILE.cc) -g -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE=1 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_REENTRANT -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iinclude -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/File.o src/File.cc +${OBJECTDIR}/src/Reader.o: src/Reader.cc + ${MKDIR} -p ${OBJECTDIR}/src + ${RM} $@.d + $(COMPILE.cc) -g -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE=1 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_REENTRANT -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iinclude -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/Reader.o src/Reader.cc + ${OBJECTDIR}/src/ConfigReader.o: src/ConfigReader.cc ${MKDIR} -p ${OBJECTDIR}/src ${RM} $@.d diff --git a/libs/IO/nbproject/Makefile-Release.mk b/libs/IO/nbproject/Makefile-Release.mk index 853a053..29ba2ae 100644 --- a/libs/IO/nbproject/Makefile-Release.mk +++ b/libs/IO/nbproject/Makefile-Release.mk @@ -35,9 +35,11 @@ OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM} # Object Files OBJECTFILES= \ + ${OBJECTDIR}/src/CommandReader.o \ ${OBJECTDIR}/src/FileRepresentation.o \ ${OBJECTDIR}/src/LineReader.o \ ${OBJECTDIR}/src/File.o \ + ${OBJECTDIR}/src/Reader.o \ ${OBJECTDIR}/src/ConfigReader.o \ ${OBJECTDIR}/src/FileReader.o \ ${OBJECTDIR}/src/FileSystem.o @@ -69,6 +71,11 @@ ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libio.a: ${OBJECTFILES} ${AR} -rv ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libio.a ${OBJECTFILES} $(RANLIB) ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libio.a +${OBJECTDIR}/src/CommandReader.o: src/CommandReader.cc + ${MKDIR} -p ${OBJECTDIR}/src + ${RM} $@.d + $(COMPILE.cc) -O2 -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/CommandReader.o src/CommandReader.cc + ${OBJECTDIR}/src/FileRepresentation.o: src/FileRepresentation.cc ${MKDIR} -p ${OBJECTDIR}/src ${RM} $@.d @@ -84,6 +91,11 @@ ${OBJECTDIR}/src/File.o: src/File.cc ${RM} $@.d $(COMPILE.cc) -O2 -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/File.o src/File.cc +${OBJECTDIR}/src/Reader.o: src/Reader.cc + ${MKDIR} -p ${OBJECTDIR}/src + ${RM} $@.d + $(COMPILE.cc) -O2 -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/Reader.o src/Reader.cc + ${OBJECTDIR}/src/ConfigReader.o: src/ConfigReader.cc ${MKDIR} -p ${OBJECTDIR}/src ${RM} $@.d diff --git a/libs/IO/nbproject/configurations.xml b/libs/IO/nbproject/configurations.xml index 7cc1823..ebf4175 100644 --- a/libs/IO/nbproject/configurations.xml +++ b/libs/IO/nbproject/configurations.xml @@ -4,12 +4,14 @@ <logicalFolder name="HeaderFiles" displayName="Header Files" projectFiles="true"> + <itemPath>include/CommandReader.h</itemPath> <itemPath>include/ConfigReader.h</itemPath> <itemPath>include/File.h</itemPath> <itemPath>include/FileReader.h</itemPath> <itemPath>include/FileRepresentation.h</itemPath> <itemPath>include/FileSystem.h</itemPath> <itemPath>include/LineReader.h</itemPath> + <itemPath>include/Reader.h</itemPath> </logicalFolder> <logicalFolder name="ResourceFiles" displayName="Resource Files" @@ -18,12 +20,14 @@ <logicalFolder name="SourceFiles" displayName="Source Files" projectFiles="true"> + <itemPath>src/CommandReader.cc</itemPath> <itemPath>src/ConfigReader.cc</itemPath> <itemPath>src/File.cc</itemPath> <itemPath>src/FileReader.cc</itemPath> <itemPath>src/FileRepresentation.cc</itemPath> <itemPath>src/FileSystem.cc</itemPath> <itemPath>src/LineReader.cc</itemPath> + <itemPath>src/Reader.cc</itemPath> </logicalFolder> <logicalFolder name="TestFiles" displayName="Test Files" diff --git a/libs/IO/src/CommandReader.cc b/libs/IO/src/CommandReader.cc new file mode 100644 index 0000000..6b67511 --- /dev/null +++ b/libs/IO/src/CommandReader.cc @@ -0,0 +1,120 @@ +/** + * ======================== legal notice ====================== + * + * File: CommandReader.cc + * Created: 30. Juli 2012, 06:42 + * 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 + * + * -------------------------------------------------------------- + */ +#include <CommandReader.h> +#include <Logging.h> +#include <stdarg.h> +#include <errno.h> +#include <wait.h> + +cCommandReader::cCommandReader(const char *cmd) + : pid(-1) +{ + args.push_back(cmd); +} + +cCommandReader::~cCommandReader() +{ + Close(); +} + +void cCommandReader::AddCommandParameter(const char* Param) +{ + args.push_back(Param); +} + +void cCommandReader::Close(void) +{ + int status; + + if (pid != waitpid(pid, &status, 0)) { + esyslog("ERROR: failed to wait for child #%d - error #%d", pid, errno); + } + else { + isyslog("child exit status: %d", WEXITSTATUS(status)); + } + pid = fd = -1; +} + +bool cCommandReader::Open(void) +{ + enum { FDRead, FDWrite }; + int parent2Child[2]; + int child2Parent[2]; + + if (pipe(parent2Child)) { + esyslog("ERROR: failed to create parent2Child-pipe #%d", errno); + return false; + } + if (pipe(child2Parent)) { + esyslog("ERROR: failed to create child2Parent-pipe #%d", errno); + return false; + } + switch ((pid = fork())) { + case -1: + esyslog("fork failed"); + return false; + + case 0: { /* child */ + const char *cmdArgs[args.size() + 1]; + + for (size_t i=0; i < args.size(); ++i) { + cmdArgs[i] = args[i].c_str(); + } + cmdArgs[args.size()] = 0; + if (dup2(parent2Child[FDRead], STDIN_FILENO) < 0) { + esyslog("ERROR: failed to create parents stdin #%d", errno); + exit(-1); + } + if (dup2(child2Parent[FDWrite], STDOUT_FILENO) < 0) { + esyslog("ERROR: failed to create childs stdout #%d", errno); + exit(-1); + } + if (dup2(child2Parent[FDWrite], STDERR_FILENO) < 0) { + esyslog("ERROR: failed to create childs stderr #%d", errno); + exit(-1); + } + if (close(parent2Child[FDWrite])) { + esyslog("ERROR: failed to close parents write-end of the pipe #%d", errno); + exit(-1); + } + if (close(child2Parent[FDRead])) { + esyslog("ERROR: failed to close childs read-end of the pipe #%d", errno); + exit(-1); + } + execv(args[0].c_str(), (char *const*) cmdArgs); + + esyslog("should never be reached!"); + exit(-1); + } break; + + default: { /* parent */ + isyslog("child process #%d started ...", pid); + fd = child2Parent[FDRead]; + + return true; + } + } + return false; +} diff --git a/libs/IO/src/File.cc b/libs/IO/src/File.cc index 9b92b55..910d24d 100644 --- a/libs/IO/src/File.cc +++ b/libs/IO/src/File.cc @@ -1,25 +1,25 @@ /** * ======================== legal notice ====================== - * + * * File: File.cc * 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 - * + * * -------------------------------------------------------------- */ #include <File.h> diff --git a/libs/IO/src/FileReader.cc b/libs/IO/src/FileReader.cc index 519c749..fd692ca 100644 --- a/libs/IO/src/FileReader.cc +++ b/libs/IO/src/FileReader.cc @@ -29,13 +29,18 @@ #include <unistd.h> cFileReader::cFileReader(cFile *Input) - : fd(-1) - , file(Input) + : file(Input) +{ + Open(); +} + +bool cFileReader::Open() { if (file && file->Exists() && file->CanRead()) { fd = open(file->AbsolutePath(), O_RDONLY); if (fd < 0) esyslog("ERROR: could not open %s", file->AbsolutePath()); } + return fd > 0; } cFileReader::~cFileReader() @@ -45,7 +50,7 @@ cFileReader::~cFileReader() void cFileReader::Close() { - if (fd >= 0) { + if (fd > 0) { close(fd); fd = -1; } @@ -54,10 +59,3 @@ void cFileReader::Close() file = NULL; } } - -int cFileReader::Read(char* buf, int bufSize) -{ - if (fd >= 0) return read(fd, buf, bufSize); - esyslog("ERROR: not an open file! %s", file->AbsolutePath()); - return 0; -} diff --git a/libs/IO/src/FileRepresentation.cc b/libs/IO/src/FileRepresentation.cc index 3366157..f74d2c8 100644 --- a/libs/IO/src/FileRepresentation.cc +++ b/libs/IO/src/FileRepresentation.cc @@ -1,25 +1,25 @@ /** * ======================== legal notice ====================== - * + * * File: FileRepresentation.cc * 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 - * + * * -------------------------------------------------------------- */ #include <FileRepresentation.h> diff --git a/libs/IO/src/LineReader.cc b/libs/IO/src/LineReader.cc index bf4bcc2..0d06628 100644 --- a/libs/IO/src/LineReader.cc +++ b/libs/IO/src/LineReader.cc @@ -23,14 +23,14 @@ * -------------------------------------------------------------- */ #include <LineReader.h> -#include <FileReader.h> +#include <Reader.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> #include <unistd.h> #include <iostream> -cLineReader::cLineReader(cFileReader *FileReader) +cLineReader::cLineReader(cReader *FileReader) : reader(FileReader) , bytesRead(0) , off(0) diff --git a/libs/IO/src/Reader.cc b/libs/IO/src/Reader.cc new file mode 100644 index 0000000..cbead31 --- /dev/null +++ b/libs/IO/src/Reader.cc @@ -0,0 +1,44 @@ +/** + * ======================== legal notice ====================== + * + * File: Reader.cc + * Created: 30. Juli 2012, 08:11 + * 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 + * + * -------------------------------------------------------------- + */ +#include <Reader.h> +#include <Logging.h> +#include <unistd.h> + +cReader::cReader() + : fd(-1) +{ +} + +cReader::~cReader() +{ +} + +int cReader::Read(char* buf, int bufSize) +{ + if (fd < 0) Open(); + if (fd > 0) return read(fd, buf, bufSize); + esyslog("ERROR: no valid filehandle to read from!"); + return 0; +} |