diff options
author | Mike Buland <eichlan@xagasoft.com> | 2014-10-03 15:54:36 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2014-10-03 15:54:36 +0000 |
commit | 0f26ab693e82d1c56ea0be653a8cd670abeb8f89 (patch) | |
tree | 34006fd7690a23a7ec49160398390d6c31e642e8 /src/unstable/archivestream.cpp | |
parent | c5f69c22ca51510da1674bf56982f8f1e3ca4a40 (diff) | |
download | libbu++-0f26ab693e82d1c56ea0be653a8cd670abeb8f89.tar.gz libbu++-0f26ab693e82d1c56ea0be653a8cd670abeb8f89.tar.bz2 libbu++-0f26ab693e82d1c56ea0be653a8cd670abeb8f89.tar.xz libbu++-0f26ab693e82d1c56ea0be653a8cd670abeb8f89.zip |
Tweaked Bu::Uuid loading to pad it's data more cleanly. This will help ensure
that we don't get valgrind errors, and is probably safer in general.
Added Bu::ArchiveStream. It could use some tweaks, but as a quick hack it's
handy to allow systems that can only read/write from/to streams to work with
archives.
Diffstat (limited to 'src/unstable/archivestream.cpp')
-rw-r--r-- | src/unstable/archivestream.cpp | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/src/unstable/archivestream.cpp b/src/unstable/archivestream.cpp new file mode 100644 index 0000000..aa45e50 --- /dev/null +++ b/src/unstable/archivestream.cpp | |||
@@ -0,0 +1,127 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007-2014 Xagasoft, All rights reserved. | ||
3 | * | ||
4 | * This file is part of the libbu++ library and is released under the | ||
5 | * terms of the license contained in the file LICENSE. | ||
6 | */ | ||
7 | |||
8 | #include "bu/archivestream.h" | ||
9 | |||
10 | Bu::ArchiveStream::ArchiveStream( Bu::ArchiveBase &ar ) : | ||
11 | ar( ar ), | ||
12 | iPos( 0 ) | ||
13 | { | ||
14 | } | ||
15 | |||
16 | Bu::ArchiveStream::~ArchiveStream() | ||
17 | { | ||
18 | } | ||
19 | |||
20 | void Bu::ArchiveStream::close() | ||
21 | { | ||
22 | ar.close(); | ||
23 | } | ||
24 | |||
25 | Bu::size Bu::ArchiveStream::read( void *pBuf, size iBytes ) | ||
26 | { | ||
27 | ar.read( pBuf, iBytes ); | ||
28 | iPos += iBytes; | ||
29 | return iBytes; | ||
30 | } | ||
31 | |||
32 | Bu::size Bu::ArchiveStream::write( const void *pBuf, size iBytes ) | ||
33 | { | ||
34 | ar.write( pBuf, iBytes ); | ||
35 | iPos += iBytes; | ||
36 | return iBytes; | ||
37 | } | ||
38 | |||
39 | Bu::size Bu::ArchiveStream::tell() | ||
40 | { | ||
41 | return iPos; | ||
42 | } | ||
43 | |||
44 | void Bu::ArchiveStream::seek( Bu::size ) | ||
45 | { | ||
46 | throw Bu::UnsupportedException(); | ||
47 | } | ||
48 | |||
49 | void Bu::ArchiveStream::setPos( Bu::size ) | ||
50 | { | ||
51 | throw Bu::UnsupportedException(); | ||
52 | } | ||
53 | |||
54 | void Bu::ArchiveStream::setPosEnd( Bu::size ) | ||
55 | { | ||
56 | throw Bu::UnsupportedException(); | ||
57 | } | ||
58 | |||
59 | bool Bu::ArchiveStream::isEos() | ||
60 | { | ||
61 | return false; | ||
62 | } | ||
63 | |||
64 | bool Bu::ArchiveStream::isOpen() | ||
65 | { | ||
66 | return true; | ||
67 | } | ||
68 | |||
69 | void Bu::ArchiveStream::flush() | ||
70 | { | ||
71 | } | ||
72 | |||
73 | bool Bu::ArchiveStream::canRead() | ||
74 | { | ||
75 | return true; | ||
76 | } | ||
77 | |||
78 | bool Bu::ArchiveStream::canWrite() | ||
79 | { | ||
80 | return true; | ||
81 | } | ||
82 | |||
83 | bool Bu::ArchiveStream::isReadable() | ||
84 | { | ||
85 | return true; | ||
86 | } | ||
87 | |||
88 | bool Bu::ArchiveStream::isWritable() | ||
89 | { | ||
90 | return true; | ||
91 | } | ||
92 | |||
93 | bool Bu::ArchiveStream::isSeekable() | ||
94 | { | ||
95 | return false; | ||
96 | } | ||
97 | |||
98 | bool Bu::ArchiveStream::isBlocking() | ||
99 | { | ||
100 | return false; | ||
101 | } | ||
102 | |||
103 | void Bu::ArchiveStream::setBlocking( bool ) | ||
104 | { | ||
105 | throw Bu::UnsupportedException(); | ||
106 | } | ||
107 | |||
108 | void Bu::ArchiveStream::setSize( Bu::size ) | ||
109 | { | ||
110 | throw Bu::UnsupportedException(); | ||
111 | } | ||
112 | |||
113 | Bu::size Bu::ArchiveStream::getSize() const | ||
114 | { | ||
115 | return iPos; | ||
116 | } | ||
117 | |||
118 | Bu::size Bu::ArchiveStream::getBlockSize() const | ||
119 | { | ||
120 | return 1; | ||
121 | } | ||
122 | |||
123 | Bu::String Bu::ArchiveStream::getLocation() const | ||
124 | { | ||
125 | return "Archive"; | ||
126 | } | ||
127 | |||