示例#1
0
/**************************************************************************
 * IStream_fnCopyTo
 */
static HRESULT WINAPI IStream_fnCopyTo(IStream *iface, IStream* pstm, ULARGE_INTEGER cb,
                                       ULARGE_INTEGER* pcbRead, ULARGE_INTEGER* pcbWritten)
{
  ISHFileStream *This = impl_from_IStream(iface);
  char copyBuff[1024];
  ULONGLONG ulSize;
  HRESULT hRet = S_OK;

  TRACE("(%p,%p,%d,%p,%p)\n", This, pstm, cb.u.LowPart, pcbRead, pcbWritten);

  if (pcbRead)
    pcbRead->QuadPart = 0;
  if (pcbWritten)
    pcbWritten->QuadPart = 0;

  if (!pstm)
    return S_OK;

  IStream_fnCommit(iface, 0); /* If ever buffered, this will be needed */

  /* Copy data */
  ulSize = cb.QuadPart;
  while (ulSize)
  {
    ULONG ulLeft, ulAmt;

    ulLeft = ulSize > sizeof(copyBuff) ? sizeof(copyBuff) : ulSize;

    /* Read */
    hRet = IStream_fnRead(iface, copyBuff, ulLeft, &ulAmt);
    if (pcbRead)
      pcbRead->QuadPart += ulAmt;
    if (FAILED(hRet) || ulAmt != ulLeft)
      break;

    /* Write */
    hRet = IStream_fnWrite(pstm, copyBuff, ulLeft, &ulAmt);
    if (pcbWritten)
      pcbWritten->QuadPart += ulAmt;
    if (FAILED(hRet) || ulAmt != ulLeft)
      break;

    ulSize -= ulLeft;
  }
  return hRet;
}
示例#2
0
/**************************************************************************
*  IStream_fnRelease
*/
static ULONG WINAPI IStream_fnRelease(IStream *iface)
{
  ISHFileStream *This = impl_from_IStream(iface);
  ULONG refCount = InterlockedDecrement(&This->ref); 

  TRACE("(%p)->(ref before=%u)\n",This, refCount + 1);
  
  if (!refCount)
  {
    IStream_fnCommit(iface, 0); /* If ever buffered, this will be needed */
    LocalFree(This->lpszPath);
    CloseHandle(This->hFile);
    HeapFree(GetProcessHeap(), 0, This);
  }
  
  return refCount;
}
示例#3
0
文件: istream.c 项目: GYGit/reactos
/**************************************************************************
 *  IStream_fnSeek
 */
static HRESULT WINAPI IStream_fnSeek(IStream *iface, LARGE_INTEGER dlibMove,
                                     DWORD dwOrigin, ULARGE_INTEGER* pNewPos)
{
  ISHFileStream *This = impl_from_IStream(iface);
  DWORD dwPos;

  TRACE("(%p,%d,%d,%p)\n", This, dlibMove.u.LowPart, dwOrigin, pNewPos);

  IStream_fnCommit(iface, 0); /* If ever buffered, this will be needed */
  dwPos = SetFilePointer(This->hFile, dlibMove.u.LowPart, NULL, dwOrigin);
  if( dwPos == INVALID_SET_FILE_POINTER )
     return HRESULT_FROM_WIN32(GetLastError());

  if (pNewPos)
  {
    pNewPos->u.HighPart = 0;
    pNewPos->u.LowPart = dwPos;
  }
  return S_OK;
}