From 0886ad4f53deb8e148f87f77b9e7ff690c02b069 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 28 Aug 2024 11:45:51 -0700 Subject: Most of the new myriad api is in. Still to go: bootstrapping reading the initial header, saving the header, growing streams as we write? --- src/stable/myriad.h | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src/stable/myriad.h') diff --git a/src/stable/myriad.h b/src/stable/myriad.h index 07b4a1d..6d99ee4 100644 --- a/src/stable/myriad.h +++ b/src/stable/myriad.h @@ -75,11 +75,14 @@ namespace Bu MyriadStream open( StreamId iStream, Mode eMode ); bool erase( StreamId iStream ); bool setSize( StreamId iStream, int32_t iNewSize ); + Bu::String getLocation() const; private: bool loadMyriad(); void createMyriad( int32_t iBlockSize, int32_t iPreallocateBlocks ); int32_t allocateBlock(); + void releaseBlock( int32_t iBlockId, bool bBlank=true ); + void blankBlock( int32_t iBlockId ); void openStream( StreamId id ); void closeStream( StreamId id ); @@ -87,7 +90,16 @@ namespace Bu * Block restricted read, it will not read past the end of the block * that iStart places it in. */ - int32_t blockRead( int32_t iStart, void *pTarget, int32_t iSize ); + int32_t blockRead( int32_t iBlock, int32_t iStart, + void *pTarget, int32_t iSize ); + + /** + * Block restricted write, it will not write past the end of the block + * that iStart places it in. If this returns a non-zero number it's an + * indication that you need to allocate a new block. + */ + int32_t blockWrite( int32_t iBlock, int32_t iStart, + const void *pTarget, int32_t iSize ); public: /** @@ -103,7 +115,15 @@ namespace Bu virtual ~Stream(); public: + int32_t getSize() const; + int32_t getBlockSize() const; + StreamId getStreamId() const; + int32_t getOpenCount() const; + + void setSize( int32_t iNewSize ); int32_t read( int32_t iStart, void *pTarget, int32_t iSize ); + int32_t write( int32_t iStart, const void *pTarget, int32_t iSize ); + Bu::String getLocation() const; /** * Doesn't actually open, just increments the open counter. @@ -134,7 +154,7 @@ namespace Bu typedef Bu::Hash StreamHash; typedef Bu::List IndexList; - Bu::Mutex mAccess; + mutable Bu::Mutex mAccess; mutable Bu::Mutex mBacking; Bu::Stream &rBacking; int32_t iBlockSize; -- cgit v1.2.3