aboutsummaryrefslogtreecommitdiff
path: root/src/stable
diff options
context:
space:
mode:
authorMike Buland <mike@xagasoft.com>2024-09-30 10:23:55 -0700
committerMike Buland <mike@xagasoft.com>2024-09-30 10:23:55 -0700
commit84c93fbf0f371bcd26893d1c33e3a5bf1a61223e (patch)
treed27e8405e81c14762c083efc20e3b936b4bd7982 /src/stable
parent76821551f312dd447a03748a01670f3718cd8345 (diff)
downloadlibbu++-84c93fbf0f371bcd26893d1c33e3a5bf1a61223e.tar.gz
libbu++-84c93fbf0f371bcd26893d1c33e3a5bf1a61223e.tar.bz2
libbu++-84c93fbf0f371bcd26893d1c33e3a5bf1a61223e.tar.xz
libbu++-84c93fbf0f371bcd26893d1c33e3a5bf1a61223e.zip
Forgot about erase, it seems to be working now.
Diffstat (limited to 'src/stable')
-rw-r--r--src/stable/myriad.cpp24
-rw-r--r--src/stable/myriad.h4
2 files changed, 26 insertions, 2 deletions
diff --git a/src/stable/myriad.cpp b/src/stable/myriad.cpp
index 0bd2ff2..eba1ebf 100644
--- a/src/stable/myriad.cpp
+++ b/src/stable/myriad.cpp
@@ -129,8 +129,30 @@ Bu::MyriadStream Bu::Myriad::open( Bu::Myriad::StreamId iStream,
129 return Bu::MyriadStream( *this, pStream, eMode ); 129 return Bu::MyriadStream( *this, pStream, eMode );
130} 130}
131 131
132void Bu::Myriad::erase( Bu::Myriad::StreamId /*iStream*/ ) 132void Bu::Myriad::erase( Bu::Myriad::StreamId iStream )
133{ 133{
134 // For now, let's prevent you from erasing a stream if it's open.
135 Bu::MutexLocker l( mhStream );
136 if( !hStream.has( iStream ) )
137 {
138 throw Bu::MyriadException( Bu::MyriadException::noSuchStream,
139 "No such stream exists.");
140 }
141 Stream *pStream = hStream.get( iStream );
142 Bu::MutexLocker sl( pStream->mAccess );
143 if( pStream->iOpenCount > 0 )
144 {
145 throw Bu::MyriadException( Bu::MyriadException::streamOpen,
146 "Cannot currently erase a stream while it is open.");
147 }
148
149 for( Bu::Array<int32_t>::iterator i = pStream->aBlocks.begin(); i; i++ )
150 {
151 releaseBlock( *i, false );
152 }
153 pStream->aBlocks.clear();
154 hStream.erase( iStream );
155 delete pStream;
134} 156}
135 157
136void Bu::Myriad::setSize( Bu::Myriad::StreamId iStream, 158void Bu::Myriad::setSize( Bu::Myriad::StreamId iStream,
diff --git a/src/stable/myriad.h b/src/stable/myriad.h
index c3f682d..60c5a39 100644
--- a/src/stable/myriad.h
+++ b/src/stable/myriad.h
@@ -25,6 +25,7 @@ namespace Bu
25 invalidParameter, 25 invalidParameter,
26 invalidBackingStream, 26 invalidBackingStream,
27 badMode, 27 badMode,
28 streamOpen,
28 }; 29 };
29 subExceptionDeclEnd(); 30 subExceptionDeclEnd();
30 31
@@ -68,7 +69,8 @@ namespace Bu
68 * 4 - 7: Size of stream in bytes 69 * 4 - 7: Size of stream in bytes
69 * 8 - ...: List of blocks in stream (4 bytes per block 70 * 8 - ...: List of blocks in stream (4 bytes per block
70 */ 71 */
71 Myriad( Bu::Stream &rBacking, int32_t iBlockSize=-1, int32_t iPreallocateBlocks=-1 ); 72 Myriad( Bu::Stream &rBacking, int32_t iBlockSize=-1,
73 int32_t iPreallocateBlocks=-1 );
72 virtual ~Myriad(); 74 virtual ~Myriad();
73 75
74 MyriadStream create( Mode eMode, int32_t iPreallocateBytes=-1 ); 76 MyriadStream create( Mode eMode, int32_t iPreallocateBytes=-1 );