aboutsummaryrefslogtreecommitdiff
path: root/src/stable/myriad.cpp
diff options
context:
space:
mode:
authorMike Buland <mike@xagasoft.com>2024-09-26 14:43:22 -0700
committerMike Buland <mike@xagasoft.com>2024-09-26 14:43:22 -0700
commit76821551f312dd447a03748a01670f3718cd8345 (patch)
treeaca702a69c9eb3f7dd8080dcd20d7f238bbbaa81 /src/stable/myriad.cpp
parentd5e966a0563e3f01c02c3cfb1f3a83fec852168b (diff)
downloadlibbu++-76821551f312dd447a03748a01670f3718cd8345.tar.gz
libbu++-76821551f312dd447a03748a01670f3718cd8345.tar.bz2
libbu++-76821551f312dd447a03748a01670f3718cd8345.tar.xz
libbu++-76821551f312dd447a03748a01670f3718cd8345.zip
Basic update to new API for existing components.
This may not all work yet, but it all compiles!
Diffstat (limited to 'src/stable/myriad.cpp')
-rw-r--r--src/stable/myriad.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/stable/myriad.cpp b/src/stable/myriad.cpp
index 1bf2301..0bd2ff2 100644
--- a/src/stable/myriad.cpp
+++ b/src/stable/myriad.cpp
@@ -74,7 +74,7 @@ Bu::MyriadStream Bu::Myriad::create( Bu::Myriad::Mode eMode,
74 mhStream.unlock(); 74 mhStream.unlock();
75 bStructureChanged = true; 75 bStructureChanged = true;
76 76
77 return Bu::MyriadStream( *this, pStream, (Mode)(eMode&ReadWrite) ); 77 return Bu::MyriadStream( *this, pStream, eMode&ReadWrite );
78} 78}
79 79
80Bu::MyriadStream Bu::Myriad::open( Bu::Myriad::StreamId iStream, 80Bu::MyriadStream Bu::Myriad::open( Bu::Myriad::StreamId iStream,
@@ -144,6 +144,18 @@ void Bu::Myriad::setSize( Bu::Myriad::StreamId iStream,
144 pStream->setSize( iNewSize ); 144 pStream->setSize( iNewSize );
145} 145}
146 146
147int32_t Bu::Myriad::getSize( StreamId iStream ) const
148{
149 Bu::MutexLocker l( mhStream );
150 return hStream.get( iStream )->getSize();
151}
152
153bool Bu::Myriad::exists( StreamId iStream ) const
154{
155 Bu::MutexLocker l( mhStream );
156 return hStream.has( iStream );
157}
158
147Bu::String Bu::Myriad::getLocation() const 159Bu::String Bu::Myriad::getLocation() const
148{ 160{
149 Bu::MutexLocker l( mAccess ); 161 Bu::MutexLocker l( mAccess );
@@ -218,6 +230,11 @@ int32_t Bu::Myriad::getTotalUnusedBytes(int32_t iAssumeBlockSize ) const
218 return iTotal; 230 return iTotal;
219} 231}
220 232
233void Bu::Myriad::sync()
234{
235 writeHeader();
236}
237
221bool Bu::Myriad::loadMyriad() 238bool Bu::Myriad::loadMyriad()
222{ 239{
223 Bu::println("Load myriad!"); 240 Bu::println("Load myriad!");
@@ -417,12 +434,12 @@ void Bu::Myriad::createMyriad( int32_t iBlockSize, int32_t iPreallocateBlocks )
417 434
418void Bu::Myriad::writeHeader() 435void Bu::Myriad::writeHeader()
419{ 436{
437 Bu::MutexLocker l( mAccess );
420 if( !rBacking.isWritable() ) 438 if( !rBacking.isWritable() )
421 return; 439 return;
422 Bu::println("Writing stream breakdown:"); 440 Bu::println("Writing stream breakdown:");
423 Bu::MemBuf mbHeader; 441 Bu::MemBuf mbHeader;
424 { 442 {
425 Bu::MutexLocker l( mAccess );
426 Bu::MutexLocker l2( mhStream ); 443 Bu::MutexLocker l2( mhStream );
427 444
428 int32_t iHdrStreamSize = __calcHeaderSize(); 445 int32_t iHdrStreamSize = __calcHeaderSize();