From 76821551f312dd447a03748a01670f3718cd8345 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 26 Sep 2024 14:43:22 -0700 Subject: Basic update to new API for existing components. This may not all work yet, but it all compiles! --- src/stable/myriad.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/stable/myriad.cpp') 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, mhStream.unlock(); bStructureChanged = true; - return Bu::MyriadStream( *this, pStream, (Mode)(eMode&ReadWrite) ); + return Bu::MyriadStream( *this, pStream, eMode&ReadWrite ); } Bu::MyriadStream Bu::Myriad::open( Bu::Myriad::StreamId iStream, @@ -144,6 +144,18 @@ void Bu::Myriad::setSize( Bu::Myriad::StreamId iStream, pStream->setSize( iNewSize ); } +int32_t Bu::Myriad::getSize( StreamId iStream ) const +{ + Bu::MutexLocker l( mhStream ); + return hStream.get( iStream )->getSize(); +} + +bool Bu::Myriad::exists( StreamId iStream ) const +{ + Bu::MutexLocker l( mhStream ); + return hStream.has( iStream ); +} + Bu::String Bu::Myriad::getLocation() const { Bu::MutexLocker l( mAccess ); @@ -218,6 +230,11 @@ int32_t Bu::Myriad::getTotalUnusedBytes(int32_t iAssumeBlockSize ) const return iTotal; } +void Bu::Myriad::sync() +{ + writeHeader(); +} + bool Bu::Myriad::loadMyriad() { Bu::println("Load myriad!"); @@ -417,12 +434,12 @@ void Bu::Myriad::createMyriad( int32_t iBlockSize, int32_t iPreallocateBlocks ) void Bu::Myriad::writeHeader() { + Bu::MutexLocker l( mAccess ); if( !rBacking.isWritable() ) return; Bu::println("Writing stream breakdown:"); Bu::MemBuf mbHeader; { - Bu::MutexLocker l( mAccess ); Bu::MutexLocker l2( mhStream ); int32_t iHdrStreamSize = __calcHeaderSize(); -- cgit v1.2.3