]> git.tdb.fi Git - libs/core.git/commitdiff
Implement get_handle in File and Pipe
authorMikko Rasa <tdb@tdb.fi>
Wed, 30 May 2012 19:02:30 +0000 (19:02 +0000)
committerMikko Rasa <tdb@tdb.fi>
Wed, 30 May 2012 19:02:30 +0000 (19:02 +0000)
source/io/file.cpp
source/io/file.h
source/io/pipe.cpp
source/io/pipe.h

index dacc5d7c0ea47b1edd5449555633b75dc9382013..862b607c9d00e08db7ce4e10bc2843ba1bd473ba 100644 (file)
@@ -153,5 +153,11 @@ SeekOffset File::tell() const
        return sys_seek(const_cast<Handle &>(handle), 0, S_CUR);
 }
 
+const Handle &File::get_handle(Mode m)
+{
+       check_access(m);
+       return handle;
+}
+
 } // namespace IO
 } // namespace Msp
index 6c7169718872a4fb5b8128723fd5ebcb28ba711c..430571f909d872854e64d11ac43917442541f121 100644 (file)
@@ -54,6 +54,8 @@ public:
 
        virtual SeekOffset seek(SeekOffset, SeekType);
        virtual SeekOffset tell() const;
+
+       virtual const Handle &get_handle(Mode);
 };
 
 inline File::CreateMode operator|(File::CreateMode m, File::CreateMode n)
index 3b74a0f2b6bea34ed7ca0a49991781de6331d6f8..639743f4ca79cab6ad1733383d69e5ff77e9556b 100644 (file)
@@ -86,5 +86,15 @@ unsigned Pipe::do_read(char *buf, unsigned size)
        return ret;
 }
 
+const Handle &Pipe::get_handle(Mode m)
+{
+       if(m==M_READ)
+               return read_handle;
+       else if(m==M_WRITE)
+               return write_handle;
+       else
+               throw invalid_argument("Pipe::get_handle");
+}
+
 } // namespace IO
 } // namespace Msp
index 6d65a9a6b2f6bc140014c281b0f7b0c01e9f4b94..d1508b2097d743b244c03f89d4230cf59cad8608 100644 (file)
@@ -26,6 +26,7 @@ protected:
        virtual unsigned do_read(char *, unsigned);
 
 public:
+       virtual const Handle &get_handle(Mode);
        virtual const Handle &get_event_handle() { return reader.get_event(); }
 };