diff options
author | Mike Buland <mike@xagasoft.com> | 2024-09-30 10:23:55 -0700 |
---|---|---|
committer | Mike Buland <mike@xagasoft.com> | 2024-09-30 10:23:55 -0700 |
commit | 84c93fbf0f371bcd26893d1c33e3a5bf1a61223e (patch) | |
tree | d27e8405e81c14762c083efc20e3b936b4bd7982 /src/stable/myriad.cpp | |
parent | 76821551f312dd447a03748a01670f3718cd8345 (diff) | |
download | libbu++-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 '')
-rw-r--r-- | src/stable/myriad.cpp | 24 |
1 files changed, 23 insertions, 1 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 | ||
132 | void Bu::Myriad::erase( Bu::Myriad::StreamId /*iStream*/ ) | 132 | void 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 | ||
136 | void Bu::Myriad::setSize( Bu::Myriad::StreamId iStream, | 158 | void Bu::Myriad::setSize( Bu::Myriad::StreamId iStream, |