| 1 | // Licensed to the .NET Foundation under one or more agreements. |
| 2 | // The .NET Foundation licenses this file to you under the MIT license. |
| 3 | // See the LICENSE file in the project root for more information. |
| 4 | //***************************************************************************** |
| 5 | // StgTiggerStream.h |
| 6 | // |
| 7 | |
| 8 | // |
| 9 | // TiggerStream is the companion to the TiggerStorage CoClass. It handles the |
| 10 | // streams managed inside of the storage and does the direct file i/o. |
| 11 | // |
| 12 | //***************************************************************************** |
| 13 | #include "stdafx.h" |
| 14 | #include "stgtiggerstream.h" |
| 15 | #include "stgtiggerstorage.h" |
| 16 | #include "posterror.h" |
| 17 | |
| 18 | // |
| 19 | // |
| 20 | // IStream |
| 21 | // |
| 22 | // |
| 23 | |
| 24 | |
| 25 | HRESULT STDMETHODCALLTYPE TiggerStream::Read( |
| 26 | void *pv, |
| 27 | ULONG cb, |
| 28 | ULONG *pcbRead) |
| 29 | { |
| 30 | return (E_NOTIMPL); |
| 31 | } |
| 32 | |
| 33 | |
| 34 | HRESULT STDMETHODCALLTYPE TiggerStream::Write( |
| 35 | const void *pv, |
| 36 | ULONG cb, |
| 37 | ULONG *pcbWritten) |
| 38 | { |
| 39 | return (m_pStorage->Write(m_rcStream, pv, cb, pcbWritten)); |
| 40 | } |
| 41 | |
| 42 | |
| 43 | HRESULT STDMETHODCALLTYPE TiggerStream::Seek( |
| 44 | LARGE_INTEGER dlibMove, |
| 45 | DWORD dwOrigin, |
| 46 | ULARGE_INTEGER *plibNewPosition) |
| 47 | { |
| 48 | return (E_NOTIMPL); |
| 49 | } |
| 50 | |
| 51 | |
| 52 | HRESULT STDMETHODCALLTYPE TiggerStream::SetSize( |
| 53 | ULARGE_INTEGER libNewSize) |
| 54 | { |
| 55 | return (E_NOTIMPL); |
| 56 | } |
| 57 | |
| 58 | |
| 59 | HRESULT STDMETHODCALLTYPE TiggerStream::CopyTo( |
| 60 | IStream *pstm, |
| 61 | ULARGE_INTEGER cb, |
| 62 | ULARGE_INTEGER *pcbRead, |
| 63 | ULARGE_INTEGER *pcbWritten) |
| 64 | { |
| 65 | return (E_NOTIMPL); |
| 66 | } |
| 67 | |
| 68 | |
| 69 | HRESULT STDMETHODCALLTYPE TiggerStream::Commit( |
| 70 | DWORD grfCommitFlags) |
| 71 | { |
| 72 | return (E_NOTIMPL); |
| 73 | } |
| 74 | |
| 75 | |
| 76 | HRESULT STDMETHODCALLTYPE TiggerStream::Revert() |
| 77 | { |
| 78 | return (E_NOTIMPL); |
| 79 | } |
| 80 | |
| 81 | |
| 82 | HRESULT STDMETHODCALLTYPE TiggerStream::LockRegion( |
| 83 | ULARGE_INTEGER libOffset, |
| 84 | ULARGE_INTEGER cb, |
| 85 | DWORD dwLockType) |
| 86 | { |
| 87 | return (E_NOTIMPL); |
| 88 | } |
| 89 | |
| 90 | |
| 91 | HRESULT STDMETHODCALLTYPE TiggerStream::UnlockRegion( |
| 92 | ULARGE_INTEGER libOffset, |
| 93 | ULARGE_INTEGER cb, |
| 94 | DWORD dwLockType) |
| 95 | { |
| 96 | return (E_NOTIMPL); |
| 97 | } |
| 98 | |
| 99 | |
| 100 | HRESULT STDMETHODCALLTYPE TiggerStream::Stat( |
| 101 | STATSTG *pstatstg, |
| 102 | DWORD grfStatFlag) |
| 103 | { |
| 104 | return (E_NOTIMPL); |
| 105 | } |
| 106 | |
| 107 | |
| 108 | HRESULT STDMETHODCALLTYPE TiggerStream::Clone( |
| 109 | IStream **ppstm) |
| 110 | { |
| 111 | return (E_NOTIMPL); |
| 112 | } |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | HRESULT TiggerStream::Init( // Return code. |
| 120 | TiggerStorage *pStorage, // Parent storage. |
| 121 | LPCSTR szStream) // Stream name. |
| 122 | { |
| 123 | // Save off the parent data source object and stream name. |
| 124 | m_pStorage = pStorage; |
| 125 | strncpy_s(m_rcStream, sizeof(m_rcStream), szStream, sizeof(m_rcStream)-1); |
| 126 | m_rcStream[sizeof(m_rcStream)-1] = '\0'; // force nul termination |
| 127 | return (S_OK); |
| 128 | } |
| 129 | |
| 130 | |
| 131 | ULONG TiggerStream::GetStreamSize() |
| 132 | { |
| 133 | PSTORAGESTREAM pStreamInfo; |
| 134 | if (FAILED(m_pStorage->FindStream(m_rcStream, &pStreamInfo))) |
| 135 | return 0; |
| 136 | return (pStreamInfo->GetSize()); |
| 137 | } |
| 138 | |