summaryrefslogtreecommitdiff
path: root/src/old/serializerbzip2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/old/serializerbzip2.cpp')
-rw-r--r--src/old/serializerbzip2.cpp88
1 files changed, 0 insertions, 88 deletions
diff --git a/src/old/serializerbzip2.cpp b/src/old/serializerbzip2.cpp
deleted file mode 100644
index bafabc8..0000000
--- a/src/old/serializerbzip2.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
1#include "serializerbzip2.h"
2#include "serializable.h"
3
4#include <bzlib.h>
5
6SerializerBZip2::SerializerBZip2(FILE *fhFile, bool bLoading):
7 Serializer(bLoading),
8 fhFile(fhFile),
9 bCloseFile(false)
10{
11 if( bLoading )
12 {
13 bzFile = BZ2_bzReadOpen( &bzerror, fhFile, 0, 0, NULL, 0 );
14 checkBZError();
15 }
16 else
17 {
18 bzFile = BZ2_bzWriteOpen( &bzerror, fhFile, 9, 0, 0 );
19 checkBZError();
20 }
21}
22
23SerializerBZip2::SerializerBZip2(char *sFileName, bool bLoading):
24 Serializer(bLoading),
25 bCloseFile(true)
26{
27 if (bLoading)
28 {
29 fhFile = fopen(sFileName, "rb");
30 bzFile = BZ2_bzReadOpen( &bzerror, fhFile, 0, 0, NULL, 0 );
31 checkBZError();
32 }
33 else
34 {
35 fhFile = fopen(sFileName, "wb");
36 bzFile = BZ2_bzWriteOpen( &bzerror, fhFile, 9, 0, 0 );
37 checkBZError();
38 }
39}
40
41SerializerBZip2::~SerializerBZip2()
42{
43 close();
44}
45
46void SerializerBZip2::checkBZError()
47{
48}
49
50void SerializerBZip2::close()
51{
52 if( bzFile != NULL )
53 {
54 if( isLoading() )
55 {
56 void *unused;
57 int nUnused;
58 BZ2_bzReadGetUnused( &bzerror, bzFile, &unused, &nUnused );
59 BZ2_bzReadClose( &bzerror, bzFile );
60 if( nUnused )
61 fseek( fhFile, -nUnused, SEEK_CUR );
62 }
63 else
64 {
65 BZ2_bzWriteClose( &bzerror, bzFile, 0, 0, 0 );
66 }
67 checkBZError();
68 bzFile = NULL;
69 }
70 if( fhFile != NULL && bCloseFile )
71 {
72 fclose(fhFile);
73 fhFile = NULL;
74 }
75}
76
77void SerializerBZip2::write(const void * pData, int32_t nSize)
78{
79 BZ2_bzWrite( &bzerror, bzFile, (void *)pData, nSize );
80 checkBZError();
81}
82
83void SerializerBZip2::read(void * pData, int32_t nSize)
84{
85 BZ2_bzRead( &bzerror, bzFile, pData, nSize );
86 checkBZError();
87}
88