diff options
| author | Mike Buland <mike@xagasoft.com> | 2024-08-28 11:45:51 -0700 |
|---|---|---|
| committer | Mike Buland <mike@xagasoft.com> | 2024-08-28 11:45:51 -0700 |
| commit | 0886ad4f53deb8e148f87f77b9e7ff690c02b069 (patch) | |
| tree | c40ccf830b944d8172566b6e3c5d4e4ca0fc7712 /src/stable/myriad.h | |
| parent | f1e3f25d9b7a12cdedb99e4cb0bfa66157a1a972 (diff) | |
| download | libbu++-0886ad4f53deb8e148f87f77b9e7ff690c02b069.tar.gz libbu++-0886ad4f53deb8e148f87f77b9e7ff690c02b069.tar.bz2 libbu++-0886ad4f53deb8e148f87f77b9e7ff690c02b069.tar.xz libbu++-0886ad4f53deb8e148f87f77b9e7ff690c02b069.zip | |
Most of the new myriad api is in.
Still to go: bootstrapping reading the initial header, saving the
header, growing streams as we write?
Diffstat (limited to '')
| -rw-r--r-- | src/stable/myriad.h | 24 |
1 files changed, 22 insertions, 2 deletions
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 | |||
| 75 | MyriadStream open( StreamId iStream, Mode eMode ); | 75 | MyriadStream open( StreamId iStream, Mode eMode ); |
| 76 | bool erase( StreamId iStream ); | 76 | bool erase( StreamId iStream ); |
| 77 | bool setSize( StreamId iStream, int32_t iNewSize ); | 77 | bool setSize( StreamId iStream, int32_t iNewSize ); |
| 78 | Bu::String getLocation() const; | ||
| 78 | 79 | ||
| 79 | private: | 80 | private: |
| 80 | bool loadMyriad(); | 81 | bool loadMyriad(); |
| 81 | void createMyriad( int32_t iBlockSize, int32_t iPreallocateBlocks ); | 82 | void createMyriad( int32_t iBlockSize, int32_t iPreallocateBlocks ); |
| 82 | int32_t allocateBlock(); | 83 | int32_t allocateBlock(); |
| 84 | void releaseBlock( int32_t iBlockId, bool bBlank=true ); | ||
| 85 | void blankBlock( int32_t iBlockId ); | ||
| 83 | 86 | ||
| 84 | void openStream( StreamId id ); | 87 | void openStream( StreamId id ); |
| 85 | void closeStream( StreamId id ); | 88 | void closeStream( StreamId id ); |
| @@ -87,7 +90,16 @@ namespace Bu | |||
| 87 | * Block restricted read, it will not read past the end of the block | 90 | * Block restricted read, it will not read past the end of the block |
| 88 | * that iStart places it in. | 91 | * that iStart places it in. |
| 89 | */ | 92 | */ |
| 90 | int32_t blockRead( int32_t iStart, void *pTarget, int32_t iSize ); | 93 | int32_t blockRead( int32_t iBlock, int32_t iStart, |
| 94 | void *pTarget, int32_t iSize ); | ||
| 95 | |||
| 96 | /** | ||
| 97 | * Block restricted write, it will not write past the end of the block | ||
| 98 | * that iStart places it in. If this returns a non-zero number it's an | ||
| 99 | * indication that you need to allocate a new block. | ||
| 100 | */ | ||
| 101 | int32_t blockWrite( int32_t iBlock, int32_t iStart, | ||
| 102 | const void *pTarget, int32_t iSize ); | ||
| 91 | 103 | ||
| 92 | public: | 104 | public: |
| 93 | /** | 105 | /** |
| @@ -103,7 +115,15 @@ namespace Bu | |||
| 103 | virtual ~Stream(); | 115 | virtual ~Stream(); |
| 104 | 116 | ||
| 105 | public: | 117 | public: |
| 118 | int32_t getSize() const; | ||
| 119 | int32_t getBlockSize() const; | ||
| 120 | StreamId getStreamId() const; | ||
| 121 | int32_t getOpenCount() const; | ||
| 122 | |||
| 123 | void setSize( int32_t iNewSize ); | ||
| 106 | int32_t read( int32_t iStart, void *pTarget, int32_t iSize ); | 124 | int32_t read( int32_t iStart, void *pTarget, int32_t iSize ); |
| 125 | int32_t write( int32_t iStart, const void *pTarget, int32_t iSize ); | ||
| 126 | Bu::String getLocation() const; | ||
| 107 | 127 | ||
| 108 | /** | 128 | /** |
| 109 | * Doesn't actually open, just increments the open counter. | 129 | * Doesn't actually open, just increments the open counter. |
| @@ -134,7 +154,7 @@ namespace Bu | |||
| 134 | typedef Bu::Hash<StreamId, Stream *> StreamHash; | 154 | typedef Bu::Hash<StreamId, Stream *> StreamHash; |
| 135 | 155 | ||
| 136 | typedef Bu::List<int32_t> IndexList; | 156 | typedef Bu::List<int32_t> IndexList; |
| 137 | Bu::Mutex mAccess; | 157 | mutable Bu::Mutex mAccess; |
| 138 | mutable Bu::Mutex mBacking; | 158 | mutable Bu::Mutex mBacking; |
| 139 | Bu::Stream &rBacking; | 159 | Bu::Stream &rBacking; |
| 140 | int32_t iBlockSize; | 160 | int32_t iBlockSize; |
