ReactOS  0.4.14-dev-317-g96040ec
stg_stream.c File Reference
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "winternl.h"
#include "wine/debug.h"
#include "storage32.h"
Include dependency graph for stg_stream.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 
#define NONAMELESSUNION
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (storage)
 
static HRESULT WINAPI StgStreamImpl_QueryInterface (IStream *iface, REFIID riid, void **ppvObject)
 
static ULONG WINAPI StgStreamImpl_AddRef (IStream *iface)
 
static ULONG WINAPI StgStreamImpl_Release (IStream *iface)
 
static HRESULT WINAPI StgStreamImpl_Read (IStream *iface, void *pv, ULONG cb, ULONG *pcbRead)
 
static HRESULT WINAPI StgStreamImpl_Write (IStream *iface, const void *pv, ULONG cb, ULONG *pcbWritten)
 
static HRESULT WINAPI StgStreamImpl_Seek (IStream *iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
 
static HRESULT WINAPI StgStreamImpl_SetSize (IStream *iface, ULARGE_INTEGER libNewSize)
 
static HRESULT WINAPI StgStreamImpl_CopyTo (IStream *iface, IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
 
static HRESULT WINAPI StgStreamImpl_Commit (IStream *iface, DWORD grfCommitFlags)
 
static HRESULT WINAPI StgStreamImpl_Revert (IStream *iface)
 
static HRESULT WINAPI StgStreamImpl_LockRegion (IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
 
static HRESULT WINAPI StgStreamImpl_UnlockRegion (IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
 
static HRESULT WINAPI StgStreamImpl_Stat (IStream *iface, STATSTG *pstatstg, DWORD grfStatFlag)
 
static HRESULT WINAPI StgStreamImpl_Clone (IStream *iface, IStream **ppstm)
 
StgStreamImplStgStreamImpl_Construct (StorageBaseImpl *parentStorage, DWORD grfMode, DirRef dirEntry)
 

Variables

static const IStreamVtbl StgStreamVtbl
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 31 of file stg_stream.c.

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 32 of file stg_stream.c.

Function Documentation

◆ StgStreamImpl_AddRef()

static ULONG WINAPI StgStreamImpl_AddRef ( IStream iface)
static

Definition at line 78 of file stg_stream.c.

80 {
82  return InterlockedIncrement(&This->ref);
83 }
#define InterlockedIncrement
Definition: armddk.h:53
static sub_stream_t * impl_from_IStream(IStream *iface)
Definition: mimeole.c:182

◆ StgStreamImpl_Clone()

static HRESULT WINAPI StgStreamImpl_Clone ( IStream iface,
IStream **  ppstm 
)
static

Definition at line 601 of file stg_stream.c.

604 {
606  StgStreamImpl* new_stream;
607  LARGE_INTEGER seek_pos;
608 
609  TRACE("%p %p\n", This, ppstm);
610 
611  /*
612  * Sanity check
613  */
614 
615  if (!This->parentStorage)
616  return STG_E_REVERTED;
617 
618  if ( ppstm == 0 )
619  return STG_E_INVALIDPOINTER;
620 
621  new_stream = StgStreamImpl_Construct (This->parentStorage, This->grfMode, This->dirEntry);
622 
623  if (!new_stream)
624  return STG_E_INSUFFICIENTMEMORY; /* Currently the only reason for new_stream=0 */
625 
626  *ppstm = &new_stream->IStream_iface;
627  IStream_AddRef(*ppstm);
628 
629  seek_pos.QuadPart = This->currentPosition.QuadPart;
630 
631  return IStream_Seek(*ppstm, seek_pos, STREAM_SEEK_SET, NULL);
632 }
#define STG_E_INVALIDPOINTER
Definition: winerror.h:2571
#define STG_E_INSUFFICIENTMEMORY
Definition: winerror.h:2570
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define STG_E_REVERTED
Definition: winerror.h:2590
IStream IStream_iface
Definition: storage32.h:429
StgStreamImpl * StgStreamImpl_Construct(StorageBaseImpl *parentStorage, DWORD grfMode, DirRef dirEntry)
Definition: stg_stream.c:666
static sub_stream_t * impl_from_IStream(IStream *iface)
Definition: mimeole.c:182
LONGLONG QuadPart
Definition: typedefs.h:112

◆ StgStreamImpl_Commit()

static HRESULT WINAPI StgStreamImpl_Commit ( IStream iface,
DWORD  grfCommitFlags 
)
static

Definition at line 467 of file stg_stream.c.

470 {
472 
473  if (!This->parentStorage)
474  {
475  WARN("storage reverted\n");
476  return STG_E_REVERTED;
477  }
478 
479  return StorageBaseImpl_Flush(This->parentStorage);
480 }
static HRESULT StorageBaseImpl_Flush(StorageBaseImpl *This)
Definition: storage32.h:268
#define WARN(fmt,...)
Definition: debug.h:111
#define STG_E_REVERTED
Definition: winerror.h:2590
static sub_stream_t * impl_from_IStream(IStream *iface)
Definition: mimeole.c:182

◆ StgStreamImpl_Construct()

StgStreamImpl* StgStreamImpl_Construct ( StorageBaseImpl parentStorage,
DWORD  grfMode,
DirRef  dirEntry 
)

Definition at line 666 of file stg_stream.c.

670 {
671  StgStreamImpl* newStream;
672 
673  newStream = HeapAlloc(GetProcessHeap(), 0, sizeof(StgStreamImpl));
674 
675  if (newStream)
676  {
677  /*
678  * Set-up the virtual function table and reference count.
679  */
680  newStream->IStream_iface.lpVtbl = &StgStreamVtbl;
681  newStream->ref = 0;
682 
683  newStream->parentStorage = parentStorage;
684 
685  /*
686  * We want to nail-down the reference to the storage in case the
687  * stream out-lives the storage in the client application.
688  *
689  * -- IStorage_AddRef(&newStream->parentStorage->IStorage_iface);
690  *
691  * No, don't do this. Some apps call IStorage_Release without
692  * calling IStream_Release first. If we grab a reference the
693  * file is not closed, and the app fails when it tries to
694  * reopen the file (Easy-PC, for example)
695  */
696 
697  newStream->grfMode = grfMode;
698  newStream->dirEntry = dirEntry;
699 
700  /*
701  * Start the stream at the beginning.
702  */
703  newStream->currentPosition.u.HighPart = 0;
704  newStream->currentPosition.u.LowPart = 0;
705 
706  /* add us to the storage's list of active streams */
707  StorageBaseImpl_AddStream(parentStorage, newStream);
708  }
709 
710  return newStream;
711 }
ULARGE_INTEGER currentPosition
Definition: storage32.h:455
DWORD grfMode
Definition: storage32.h:445
struct _ULARGE_INTEGER::@3770 u
static const IStreamVtbl StgStreamVtbl
Definition: stg_stream.c:637
DirRef dirEntry
Definition: storage32.h:450
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
StorageBaseImpl * parentStorage
Definition: storage32.h:440
void StorageBaseImpl_AddStream(StorageBaseImpl *stg, StgStreamImpl *strm)
Definition: storage32.c:2714
IStream IStream_iface
Definition: storage32.h:429

Referenced by StgStreamImpl_Clone(), StorageBaseImpl_CopyChildEntryTo(), StorageBaseImpl_CreateStream(), and StorageBaseImpl_OpenStream().

◆ StgStreamImpl_CopyTo()

static HRESULT WINAPI StgStreamImpl_CopyTo ( IStream iface,
IStream pstm,
ULARGE_INTEGER  cb,
ULARGE_INTEGER pcbRead,
ULARGE_INTEGER pcbWritten 
)
static

Definition at line 389 of file stg_stream.c.

395 {
397  HRESULT hr = S_OK;
398  BYTE tmpBuffer[128];
399  ULONG bytesRead, bytesWritten, copySize;
400  ULARGE_INTEGER totalBytesRead;
401  ULARGE_INTEGER totalBytesWritten;
402 
403  TRACE("(%p, %p, %d, %p, %p)\n",
404  iface, pstm, cb.u.LowPart, pcbRead, pcbWritten);
405 
406  /*
407  * Sanity check
408  */
409 
410  if (!This->parentStorage)
411  {
412  WARN("storage reverted\n");
413  return STG_E_REVERTED;
414  }
415 
416  if ( pstm == 0 )
417  return STG_E_INVALIDPOINTER;
418 
419  totalBytesRead.QuadPart = 0;
420  totalBytesWritten.QuadPart = 0;
421 
422  while ( cb.QuadPart > 0 )
423  {
424  if ( cb.QuadPart >= sizeof(tmpBuffer) )
425  copySize = sizeof(tmpBuffer);
426  else
427  copySize = cb.u.LowPart;
428 
429  IStream_Read(iface, tmpBuffer, copySize, &bytesRead);
430 
431  totalBytesRead.QuadPart += bytesRead;
432 
433  IStream_Write(pstm, tmpBuffer, bytesRead, &bytesWritten);
434 
435  totalBytesWritten.QuadPart += bytesWritten;
436 
437  /*
438  * Check that read & write operations were successful
439  */
440  if (bytesRead != bytesWritten)
441  {
443  WARN("medium full\n");
444  break;
445  }
446 
447  if (bytesRead!=copySize)
448  cb.QuadPart = 0;
449  else
450  cb.QuadPart -= bytesRead;
451  }
452 
453  if (pcbRead) pcbRead->QuadPart = totalBytesRead.QuadPart;
454  if (pcbWritten) pcbWritten->QuadPart = totalBytesWritten.QuadPart;
455 
456  return hr;
457 }
HRESULT hr
Definition: shlfolder.c:183
#define STG_E_INVALIDPOINTER
Definition: winerror.h:2571
#define WARN(fmt,...)
Definition: debug.h:111
#define STG_E_MEDIUMFULL
Definition: winerror.h:2581
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
unsigned char BYTE
Definition: mem.h:68
GLenum GLsizei GLuint GLint * bytesWritten
Definition: glext.h:11123
#define S_OK
Definition: intsafe.h:59
#define STG_E_REVERTED
Definition: winerror.h:2590
static HMODULE MODULEINFO DWORD cb
Definition: module.c:32
unsigned int ULONG
Definition: retypes.h:1
static sub_stream_t * impl_from_IStream(IStream *iface)
Definition: mimeole.c:182

◆ StgStreamImpl_LockRegion()

static HRESULT WINAPI StgStreamImpl_LockRegion ( IStream iface,
ULARGE_INTEGER  libOffset,
ULARGE_INTEGER  cb,
DWORD  dwLockType 
)
static

Definition at line 496 of file stg_stream.c.

501 {
503 
504  if (!This->parentStorage)
505  {
506  WARN("storage reverted\n");
507  return STG_E_REVERTED;
508  }
509 
510  FIXME("not implemented!\n");
511  return E_NOTIMPL;
512 }
#define WARN(fmt,...)
Definition: debug.h:111
#define FIXME(fmt,...)
Definition: debug.h:110
#define STG_E_REVERTED
Definition: winerror.h:2590
#define E_NOTIMPL
Definition: ddrawi.h:99
static sub_stream_t * impl_from_IStream(IStream *iface)
Definition: mimeole.c:182

◆ StgStreamImpl_QueryInterface()

static HRESULT WINAPI StgStreamImpl_QueryInterface ( IStream iface,
REFIID  riid,
void **  ppvObject 
)
static

Definition at line 48 of file stg_stream.c.

52 {
54 
55  if (ppvObject==0)
56  return E_INVALIDARG;
57 
58  *ppvObject = 0;
59 
60  if (IsEqualIID(&IID_IUnknown, riid) ||
61  IsEqualIID(&IID_ISequentialStream, riid) ||
62  IsEqualIID(&IID_IStream, riid))
63  {
64  *ppvObject = &This->IStream_iface;
65  }
66  else
67  return E_NOINTERFACE;
68 
69  IStream_AddRef(iface);
70 
71  return S_OK;
72 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
#define E_INVALIDARG
Definition: ddrawi.h:101
const GUID IID_IUnknown
REFIID LPVOID * ppvObject
Definition: precomp.h:44
#define S_OK
Definition: intsafe.h:59
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
static sub_stream_t * impl_from_IStream(IStream *iface)
Definition: mimeole.c:182

◆ StgStreamImpl_Read()

static HRESULT WINAPI StgStreamImpl_Read ( IStream iface,
void pv,
ULONG  cb,
ULONG pcbRead 
)
static

Definition at line 128 of file stg_stream.c.

133 {
135 
136  ULONG bytesReadBuffer;
137  HRESULT res;
138 
139  TRACE("(%p, %p, %d, %p)\n",
140  iface, pv, cb, pcbRead);
141 
142  if (!This->parentStorage)
143  {
144  WARN("storage reverted\n");
145  return STG_E_REVERTED;
146  }
147 
148  /*
149  * If the caller is not interested in the number of bytes read,
150  * we use another buffer to avoid "if" statements in the code.
151  */
152  if (pcbRead==0)
153  pcbRead = &bytesReadBuffer;
154 
155  res = StorageBaseImpl_StreamReadAt(This->parentStorage,
156  This->dirEntry,
157  This->currentPosition,
158  cb,
159  pv,
160  pcbRead);
161 
162  if (SUCCEEDED(res))
163  {
164  /*
165  * Advance the pointer for the number of positions read.
166  */
167  This->currentPosition.QuadPart += *pcbRead;
168  }
169 
170  TRACE("<-- %08x\n", res);
171  return res;
172 }
#define WARN(fmt,...)
Definition: debug.h:111
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
#define STG_E_REVERTED
Definition: winerror.h:2590
static HRESULT StorageBaseImpl_StreamReadAt(StorageBaseImpl *This, DirRef index, ULARGE_INTEGER offset, ULONG size, void *buffer, ULONG *bytesRead)
Definition: storage32.h:303
static HMODULE MODULEINFO DWORD cb
Definition: module.c:32
GLuint res
Definition: glext.h:9613
unsigned int ULONG
Definition: retypes.h:1
static sub_stream_t * impl_from_IStream(IStream *iface)
Definition: mimeole.c:182
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ StgStreamImpl_Release()

static ULONG WINAPI StgStreamImpl_Release ( IStream iface)
static

Definition at line 89 of file stg_stream.c.

91 {
94 
95  if (!ref)
96  {
97  TRACE("(%p)\n", This);
98 
99  /*
100  * Release the reference we are holding on the parent storage.
101  * IStorage_Release(&This->parentStorage->IStorage_iface);
102  *
103  * No, don't do this. Some apps call IStorage_Release without
104  * calling IStream_Release first. If we grab a reference the
105  * file is not closed, and the app fails when it tries to
106  * reopen the file (Easy-PC, for example). Just inform the
107  * storage that we have closed the stream
108  */
109 
110  if (This->parentStorage)
111  StorageBaseImpl_RemoveStream(This->parentStorage, This);
112  This->parentStorage = 0;
114  }
115 
116  return ref;
117 }
void StorageBaseImpl_RemoveStream(StorageBaseImpl *stg, StgStreamImpl *strm)
Definition: storage32.c:2720
Definition: send.c:47
GLenum GLint ref
Definition: glext.h:6028
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
#define InterlockedDecrement
Definition: armddk.h:52
unsigned int ULONG
Definition: retypes.h:1
#define HeapFree(x, y, z)
Definition: compat.h:394
static sub_stream_t * impl_from_IStream(IStream *iface)
Definition: mimeole.c:182

◆ StgStreamImpl_Revert()

static HRESULT WINAPI StgStreamImpl_Revert ( IStream iface)
static

Definition at line 490 of file stg_stream.c.

492 {
493  return S_OK;
494 }
#define S_OK
Definition: intsafe.h:59

◆ StgStreamImpl_Seek()

static HRESULT WINAPI StgStreamImpl_Seek ( IStream iface,
LARGE_INTEGER  dlibMove,
DWORD  dwOrigin,
ULARGE_INTEGER plibNewPosition 
)
static

Definition at line 265 of file stg_stream.c.

270 {
272 
273  ULARGE_INTEGER newPosition;
274  DirEntry currentEntry;
275  HRESULT hr;
276 
277  TRACE("(%p, %d, %d, %p)\n",
278  iface, dlibMove.u.LowPart, dwOrigin, plibNewPosition);
279 
280  /*
281  * fail if the stream has no parent (as does windows)
282  */
283 
284  if (!This->parentStorage)
285  {
286  WARN("storage reverted\n");
287  return STG_E_REVERTED;
288  }
289 
290  /*
291  * The caller is allowed to pass in NULL as the new position return value.
292  * If it happens, we assign it to a dynamic variable to avoid special cases
293  * in the code below.
294  */
295  if (plibNewPosition == 0)
296  {
297  plibNewPosition = &newPosition;
298  }
299 
300  /*
301  * The file pointer is moved depending on the given "function"
302  * parameter.
303  */
304  switch (dwOrigin)
305  {
306  case STREAM_SEEK_SET:
307  plibNewPosition->u.HighPart = 0;
308  plibNewPosition->u.LowPart = 0;
309  break;
310  case STREAM_SEEK_CUR:
311  *plibNewPosition = This->currentPosition;
312  break;
313  case STREAM_SEEK_END:
314  hr = StorageBaseImpl_ReadDirEntry(This->parentStorage, This->dirEntry, &currentEntry);
315  if (FAILED(hr)) return hr;
316  *plibNewPosition = currentEntry.size;
317  break;
318  default:
319  WARN("invalid dwOrigin %d\n", dwOrigin);
320  return STG_E_INVALIDFUNCTION;
321  }
322 
323  plibNewPosition->QuadPart += dlibMove.QuadPart;
324 
325  /*
326  * tell the caller what we calculated
327  */
328  This->currentPosition = *plibNewPosition;
329 
330  return S_OK;
331 }
HRESULT hr
Definition: shlfolder.c:183
ULARGE_INTEGER size
Definition: storage32.h:157
#define WARN(fmt,...)
Definition: debug.h:111
struct _ULARGE_INTEGER::@3770 u
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
#define STG_E_INVALIDFUNCTION
Definition: winerror.h:2564
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
#define S_OK
Definition: intsafe.h:59
#define STG_E_REVERTED
Definition: winerror.h:2590
static HRESULT StorageBaseImpl_ReadDirEntry(StorageBaseImpl *This, DirRef index, DirEntry *data)
Definition: storage32.h:290
struct _LARGE_INTEGER::@2221 u
static sub_stream_t * impl_from_IStream(IStream *iface)
Definition: mimeole.c:182
LONGLONG QuadPart
Definition: typedefs.h:112

◆ StgStreamImpl_SetSize()

static HRESULT WINAPI StgStreamImpl_SetSize ( IStream iface,
ULARGE_INTEGER  libNewSize 
)
static

Definition at line 340 of file stg_stream.c.

343 {
345 
346  HRESULT hr;
347 
348  TRACE("(%p, %d)\n", iface, libNewSize.u.LowPart);
349 
350  if(!This->parentStorage)
351  {
352  WARN("storage reverted\n");
353  return STG_E_REVERTED;
354  }
355 
356  /*
357  * As documented.
358  */
359  if (libNewSize.u.HighPart != 0)
360  {
361  WARN("invalid value for libNewSize.u.HighPart %d\n", libNewSize.u.HighPart);
362  return STG_E_INVALIDFUNCTION;
363  }
364 
365  /*
366  * Do we have permission?
367  */
368  if (!(This->grfMode & (STGM_WRITE | STGM_READWRITE)))
369  {
370  WARN("access denied\n");
371  return STG_E_ACCESSDENIED;
372  }
373 
374  hr = StorageBaseImpl_StreamSetSize(This->parentStorage, This->dirEntry, libNewSize);
375 
376  if (SUCCEEDED(hr))
377  hr = StorageBaseImpl_Flush(This->parentStorage);
378 
379  return hr;
380 }
static HRESULT StorageBaseImpl_Flush(StorageBaseImpl *This)
Definition: storage32.h:268
HRESULT hr
Definition: shlfolder.c:183
#define WARN(fmt,...)
Definition: debug.h:111
struct _ULARGE_INTEGER::@3770 u
#define STG_E_ACCESSDENIED
Definition: winerror.h:2568
#define STGM_WRITE
Definition: objbase.h:917
#define STG_E_INVALIDFUNCTION
Definition: winerror.h:2564
#define TRACE(s)
Definition: solgame.cpp:4
static HRESULT StorageBaseImpl_StreamSetSize(StorageBaseImpl *This, DirRef index, ULARGE_INTEGER newsize)
Definition: storage32.h:317
LONG HRESULT
Definition: typedefs.h:77
#define STGM_READWRITE
Definition: objbase.h:918
#define STG_E_REVERTED
Definition: winerror.h:2590
static sub_stream_t * impl_from_IStream(IStream *iface)
Definition: mimeole.c:182
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ StgStreamImpl_Stat()

static HRESULT WINAPI StgStreamImpl_Stat ( IStream iface,
STATSTG *  pstatstg,
DWORD  grfStatFlag 
)
static

Definition at line 540 of file stg_stream.c.

544 {
546 
547  DirEntry currentEntry;
548  HRESULT hr;
549 
550  TRACE("%p %p %d\n", This, pstatstg, grfStatFlag);
551 
552  /*
553  * if stream has no parent, return STG_E_REVERTED
554  */
555 
556  if (!This->parentStorage)
557  {
558  WARN("storage reverted\n");
559  return STG_E_REVERTED;
560  }
561 
562  /*
563  * Read the information from the directory entry.
564  */
565  hr = StorageBaseImpl_ReadDirEntry(This->parentStorage,
566  This->dirEntry,
567  &currentEntry);
568 
569  if (SUCCEEDED(hr))
570  {
571  StorageUtl_CopyDirEntryToSTATSTG(This->parentStorage,
572  pstatstg,
573  &currentEntry,
574  grfStatFlag);
575 
576  pstatstg->grfMode = This->grfMode;
577 
578  /* In simple create mode cbSize is the current pos */
579  if((This->parentStorage->openFlags & STGM_SIMPLE) && This->parentStorage->create)
580  pstatstg->cbSize = This->currentPosition;
581 
582  return S_OK;
583  }
584 
585  WARN("failed to read entry\n");
586  return hr;
587 }
HRESULT hr
Definition: shlfolder.c:183
#define WARN(fmt,...)
Definition: debug.h:111
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
#define S_OK
Definition: intsafe.h:59
#define STG_E_REVERTED
Definition: winerror.h:2590
void StorageUtl_CopyDirEntryToSTATSTG(StorageBaseImpl *storage, STATSTG *destination, const DirEntry *source, int statFlags)
Definition: storage32.c:7017
static HRESULT StorageBaseImpl_ReadDirEntry(StorageBaseImpl *This, DirRef index, DirEntry *data)
Definition: storage32.h:290
#define STGM_SIMPLE
Definition: objbase.h:915
static sub_stream_t * impl_from_IStream(IStream *iface)
Definition: mimeole.c:182
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ StgStreamImpl_UnlockRegion()

static HRESULT WINAPI StgStreamImpl_UnlockRegion ( IStream iface,
ULARGE_INTEGER  libOffset,
ULARGE_INTEGER  cb,
DWORD  dwLockType 
)
static

Definition at line 514 of file stg_stream.c.

519 {
521 
522  if (!This->parentStorage)
523  {
524  WARN("storage reverted\n");
525  return STG_E_REVERTED;
526  }
527 
528  FIXME("not implemented!\n");
529  return E_NOTIMPL;
530 }
#define WARN(fmt,...)
Definition: debug.h:111
#define FIXME(fmt,...)
Definition: debug.h:110
#define STG_E_REVERTED
Definition: winerror.h:2590
#define E_NOTIMPL
Definition: ddrawi.h:99
static sub_stream_t * impl_from_IStream(IStream *iface)
Definition: mimeole.c:182

◆ StgStreamImpl_Write()

static HRESULT WINAPI StgStreamImpl_Write ( IStream iface,
const void pv,
ULONG  cb,
ULONG pcbWritten 
)
static

Definition at line 184 of file stg_stream.c.

189 {
191 
192  ULONG bytesWritten = 0;
193  HRESULT res;
194 
195  TRACE("(%p, %p, %d, %p)\n",
196  iface, pv, cb, pcbWritten);
197 
198  /*
199  * Do we have permission to write to this stream?
200  */
201  switch(STGM_ACCESS_MODE(This->grfMode))
202  {
203  case STGM_WRITE:
204  case STGM_READWRITE:
205  break;
206  default:
207  WARN("access denied by flags: 0x%x\n", STGM_ACCESS_MODE(This->grfMode));
208  return STG_E_ACCESSDENIED;
209  }
210 
211  if (!pv)
212  return STG_E_INVALIDPOINTER;
213 
214  if (!This->parentStorage)
215  {
216  WARN("storage reverted\n");
217  return STG_E_REVERTED;
218  }
219 
220  /*
221  * If the caller is not interested in the number of bytes written,
222  * we use another buffer to avoid "if" statements in the code.
223  */
224  if (pcbWritten == 0)
225  pcbWritten = &bytesWritten;
226 
227  /*
228  * Initialize the out parameter
229  */
230  *pcbWritten = 0;
231 
232  if (cb == 0)
233  {
234  TRACE("<-- S_OK, written 0\n");
235  return S_OK;
236  }
237 
238  res = StorageBaseImpl_StreamWriteAt(This->parentStorage,
239  This->dirEntry,
240  This->currentPosition,
241  cb,
242  pv,
243  pcbWritten);
244 
245  /*
246  * Advance the position pointer for the number of positions written.
247  */
248  This->currentPosition.QuadPart += *pcbWritten;
249 
250  if (SUCCEEDED(res))
251  res = StorageBaseImpl_Flush(This->parentStorage);
252 
253  TRACE("<-- %08x, written %u\n", res, *pcbWritten);
254  return res;
255 }
static HRESULT StorageBaseImpl_Flush(StorageBaseImpl *This)
Definition: storage32.h:268
#define STG_E_INVALIDPOINTER
Definition: winerror.h:2571
#define WARN(fmt,...)
Definition: debug.h:111
#define STG_E_ACCESSDENIED
Definition: winerror.h:2568
#define STGM_WRITE
Definition: objbase.h:917
#define TRACE(s)
Definition: solgame.cpp:4
static HRESULT StorageBaseImpl_StreamWriteAt(StorageBaseImpl *This, DirRef index, ULARGE_INTEGER offset, ULONG size, const void *buffer, ULONG *bytesWritten)
Definition: storage32.h:311
LONG HRESULT
Definition: typedefs.h:77
#define STGM_READWRITE
Definition: objbase.h:918
#define STGM_ACCESS_MODE(stgm)
Definition: storage32.h:115
GLenum GLsizei GLuint GLint * bytesWritten
Definition: glext.h:11123
#define S_OK
Definition: intsafe.h:59
#define STG_E_REVERTED
Definition: winerror.h:2590
static HMODULE MODULEINFO DWORD cb
Definition: module.c:32
GLuint res
Definition: glext.h:9613
unsigned int ULONG
Definition: retypes.h:1
static sub_stream_t * impl_from_IStream(IStream *iface)
Definition: mimeole.c:182
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( storage  )

Variable Documentation

◆ StgStreamVtbl

const IStreamVtbl StgStreamVtbl
static
Initial value:
=
{
}
static HRESULT WINAPI StgStreamImpl_Seek(IStream *iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
Definition: stg_stream.c:265
static HRESULT WINAPI StgStreamImpl_UnlockRegion(IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
Definition: stg_stream.c:514
static HRESULT WINAPI StgStreamImpl_SetSize(IStream *iface, ULARGE_INTEGER libNewSize)
Definition: stg_stream.c:340
static HRESULT WINAPI StgStreamImpl_Clone(IStream *iface, IStream **ppstm)
Definition: stg_stream.c:601
static HRESULT WINAPI StgStreamImpl_Stat(IStream *iface, STATSTG *pstatstg, DWORD grfStatFlag)
Definition: stg_stream.c:540
static HRESULT WINAPI StgStreamImpl_LockRegion(IStream *iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
Definition: stg_stream.c:496
static HRESULT WINAPI StgStreamImpl_Revert(IStream *iface)
Definition: stg_stream.c:490
static HRESULT WINAPI StgStreamImpl_Read(IStream *iface, void *pv, ULONG cb, ULONG *pcbRead)
Definition: stg_stream.c:128
static ULONG WINAPI StgStreamImpl_AddRef(IStream *iface)
Definition: stg_stream.c:78
static HRESULT WINAPI StgStreamImpl_Write(IStream *iface, const void *pv, ULONG cb, ULONG *pcbWritten)
Definition: stg_stream.c:184
static HRESULT WINAPI StgStreamImpl_CopyTo(IStream *iface, IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
Definition: stg_stream.c:389
static HRESULT WINAPI StgStreamImpl_QueryInterface(IStream *iface, REFIID riid, void **ppvObject)
Definition: stg_stream.c:48
static HRESULT WINAPI StgStreamImpl_Commit(IStream *iface, DWORD grfCommitFlags)
Definition: stg_stream.c:467
static ULONG WINAPI StgStreamImpl_Release(IStream *iface)
Definition: stg_stream.c:89

Definition at line 637 of file stg_stream.c.

Referenced by StgStreamImpl_Construct().