summaryrefslogtreecommitdiff
path: root/src/unstable/fifo.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-11-05 22:41:51 +0000
committerMike Buland <eichlan@xagasoft.com>2012-11-05 22:41:51 +0000
commitec05778d5718a7912e506764d443a78d6a6179e3 (patch)
tree78a9a01532180030c095acefc45763f07c14edb8 /src/unstable/fifo.cpp
parentb20414ac1fe80a71a90601f4cd1767fa7014a9ba (diff)
downloadlibbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.gz
libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.bz2
libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.xz
libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.zip
Converted tabs to spaces with tabconv.
Diffstat (limited to 'src/unstable/fifo.cpp')
-rw-r--r--src/unstable/fifo.cpp118
1 files changed, 59 insertions, 59 deletions
diff --git a/src/unstable/fifo.cpp b/src/unstable/fifo.cpp
index 6f327df..4b4a2bf 100644
--- a/src/unstable/fifo.cpp
+++ b/src/unstable/fifo.cpp
@@ -17,75 +17,75 @@
17namespace Bu { subExceptionDef( FifoException ) } 17namespace Bu { subExceptionDef( FifoException ) }
18 18
19Bu::Fifo::Fifo( const Bu::String &sName, int iFlags, mode_t mAcc ) : 19Bu::Fifo::Fifo( const Bu::String &sName, int iFlags, mode_t mAcc ) :
20 iFlags( iFlags ), 20 iFlags( iFlags ),
21 iIn( -1 ), 21 iIn( -1 ),
22 iOut( -1 ) 22 iOut( -1 )
23{ 23{
24#ifndef WIN32 24#ifndef WIN32
25 if( iFlags&Create ) 25 if( iFlags&Create )
26 { 26 {
27 if( mkfifo( sName.getStr(), mAcc ) ) 27 if( mkfifo( sName.getStr(), mAcc ) )
28 { 28 {
29 throw FifoException("Error creating fifo: %s\n", strerror( errno ) ); 29 throw FifoException("Error creating fifo: %s\n", strerror( errno ) );
30 } 30 }
31 } 31 }
32 if( iFlags&Read ) 32 if( iFlags&Read )
33 { 33 {
34 iIn = ::open( 34 iIn = ::open(
35 sName.getStr(), 35 sName.getStr(),
36 O_RDONLY|((iFlags&NonBlock)?O_NONBLOCK:0) 36 O_RDONLY|((iFlags&NonBlock)?O_NONBLOCK:0)
37 ); 37 );
38 } 38 }
39 if( iFlags&Write ) 39 if( iFlags&Write )
40 { 40 {
41 iOut = ::open( 41 iOut = ::open(
42 sName.getStr(), 42 sName.getStr(),
43 O_WRONLY 43 O_WRONLY
44 ); 44 );
45 } 45 }
46#else 46#else
47 #warning Bu::Fifo::Fifo IS A STUB for WIN32!!!! 47 #warning Bu::Fifo::Fifo IS A STUB for WIN32!!!!
48#endif 48#endif
49} 49}
50 50
51Bu::Fifo::~Fifo() 51Bu::Fifo::~Fifo()
52{ 52{
53 close(); 53 close();
54} 54}
55 55
56void Bu::Fifo::close() 56void Bu::Fifo::close()
57{ 57{
58 if( iIn > -1 ) 58 if( iIn > -1 )
59 { 59 {
60 ::close( iIn ); 60 ::close( iIn );
61 iIn = -1; 61 iIn = -1;
62 } 62 }
63 if( iOut > -1 ) 63 if( iOut > -1 )
64 { 64 {
65 ::close( iOut ); 65 ::close( iOut );
66 iOut = -1; 66 iOut = -1;
67 } 67 }
68} 68}
69 69
70Bu::size Bu::Fifo::read( void *pBuf, Bu::size nBytes ) 70Bu::size Bu::Fifo::read( void *pBuf, Bu::size nBytes )
71{ 71{
72 if( iIn < 0 ) 72 if( iIn < 0 )
73 throw FifoException("Fifo not open for reading."); 73 throw FifoException("Fifo not open for reading.");
74 74
75 return TEMP_FAILURE_RETRY( ::read( iIn, pBuf, nBytes ) ); 75 return TEMP_FAILURE_RETRY( ::read( iIn, pBuf, nBytes ) );
76} 76}
77 77
78Bu::size Bu::Fifo::write( const void *pBuf, Bu::size nBytes ) 78Bu::size Bu::Fifo::write( const void *pBuf, Bu::size nBytes )
79{ 79{
80 if( iOut < 0 ) 80 if( iOut < 0 )
81 throw FifoException("Fifo not open for writing."); 81 throw FifoException("Fifo not open for writing.");
82 82
83 return TEMP_FAILURE_RETRY( ::write( iOut, pBuf, nBytes ) ); 83 return TEMP_FAILURE_RETRY( ::write( iOut, pBuf, nBytes ) );
84} 84}
85 85
86Bu::size Bu::Fifo::tell() 86Bu::size Bu::Fifo::tell()
87{ 87{
88 return -1; 88 return -1;
89} 89}
90 90
91void Bu::Fifo::seek( Bu::size ) 91void Bu::Fifo::seek( Bu::size )
@@ -102,53 +102,53 @@ void Bu::Fifo::setPosEnd( Bu::size )
102 102
103bool Bu::Fifo::isEos() 103bool Bu::Fifo::isEos()
104{ 104{
105 return false; 105 return false;
106} 106}
107 107
108bool Bu::Fifo::canRead() 108bool Bu::Fifo::canRead()
109{ 109{
110 return (iIn>-1); 110 return (iIn>-1);
111} 111}
112 112
113bool Bu::Fifo::canWrite() 113bool Bu::Fifo::canWrite()
114{ 114{
115 return (iOut>-1); 115 return (iOut>-1);
116} 116}
117 117
118bool Bu::Fifo::isReadable() 118bool Bu::Fifo::isReadable()
119{ 119{
120 return (iIn>-1); 120 return (iIn>-1);
121} 121}
122 122
123bool Bu::Fifo::isWritable() 123bool Bu::Fifo::isWritable()
124{ 124{
125 return (iOut>-1); 125 return (iOut>-1);
126} 126}
127 127
128bool Bu::Fifo::isSeekable() 128bool Bu::Fifo::isSeekable()
129{ 129{
130 return false; 130 return false;
131} 131}
132 132
133bool Bu::Fifo::isBlocking() 133bool Bu::Fifo::isBlocking()
134{ 134{
135#ifndef WIN32 135#ifndef WIN32
136 return ((fcntl( iIn, F_GETFL, 0 )&O_NONBLOCK) == O_NONBLOCK); 136 return ((fcntl( iIn, F_GETFL, 0 )&O_NONBLOCK) == O_NONBLOCK);
137#else 137#else
138 #warning Bu::Fifo::isBlocking IS A STUB for WIN32!!!! 138 #warning Bu::Fifo::isBlocking IS A STUB for WIN32!!!!
139#endif 139#endif
140} 140}
141 141
142void Bu::Fifo::setBlocking( bool bBlocking ) 142void Bu::Fifo::setBlocking( bool bBlocking )
143{ 143{
144#ifndef WIN32 144#ifndef WIN32
145 if( bBlocking ) 145 if( bBlocking )
146 fcntl( iIn, F_SETFL, fcntl( iIn, F_GETFL, 0 )&(~O_NONBLOCK) ); 146 fcntl( iIn, F_SETFL, fcntl( iIn, F_GETFL, 0 )&(~O_NONBLOCK) );
147 else 147 else
148 fcntl( iIn, F_SETFL, fcntl( iIn, F_GETFL, 0 )|O_NONBLOCK ); 148 fcntl( iIn, F_SETFL, fcntl( iIn, F_GETFL, 0 )|O_NONBLOCK );
149#else 149#else
150 #warning Bu::Fifo::setBlocking IS A STUB for WIN32!!!! 150 #warning Bu::Fifo::setBlocking IS A STUB for WIN32!!!!
151#endif 151#endif
152} 152}
153 153
154void Bu::Fifo::flush() 154void Bu::Fifo::flush()
@@ -157,6 +157,6 @@ void Bu::Fifo::flush()
157 157
158bool Bu::Fifo::isOpen() 158bool Bu::Fifo::isOpen()
159{ 159{
160 return (iIn > -1) || (iOut > -1); 160 return (iIn > -1) || (iOut > -1);
161} 161}
162 162