"Fossies" - the Fresh Open Source Software Archive 
Member "muscle/zlib/GZDataIO.cpp" (21 Nov 2020, 1140 Bytes) of package /linux/privat/muscle7.62.zip:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "GZDataIO.cpp" see the
Fossies "Dox" file reference documentation.
1 /* This file is Copyright 2000-2013 Meyer Sound Laboratories Inc. See the included LICENSE.txt file for details. */
2
3 #ifdef MUSCLE_ENABLE_ZLIB_ENCODING
4
5 #include "zlib/GZDataIO.h"
6
7 namespace muscle {
8
9 GZDataIO :: GZDataIO(const char * filePath, const char * mode)
10 : _file(gzopen(filePath, mode))
11 {
12 // empty
13 }
14
15 GZDataIO :: ~GZDataIO()
16 {
17 ShutdownAux();
18 }
19
20 int32 GZDataIO :: Read(void * buffer, uint32 size)
21 {
22 if (_file == NULL) return -1;
23 return gzread(_file, buffer, size);
24 }
25
26 int32 GZDataIO :: Write(const void * buffer, uint32 size)
27 {
28 if (_file == NULL) return -1;
29 return gzwrite(_file, buffer, size);
30 }
31
32 void GZDataIO :: FlushOutput()
33 {
34 if (_file) (void) gzflush(_file, Z_BLOCK);
35 }
36
37 void GZDataIO :: Shutdown()
38 {
39 ShutdownAux();
40 }
41
42 void GZDataIO :: ShutdownAux()
43 {
44 if (_file)
45 {
46 gzclose(_file);
47 _file = NULL;
48 }
49 }
50
51 const ConstSocketRef & GZDataIO :: GetReadSelectSocket() const
52 {
53 return GetDefaultObjectForType<ConstSocketRef>();
54 }
55
56 const ConstSocketRef & GZDataIO :: GetWriteSelectSocket() const
57 {
58 return GetDefaultObjectForType<ConstSocketRef>();
59 }
60
61 } // end namespace muscle
62
63 #endif