clone method

IStream? clone()

Creates a new stream object with its own seek pointer that references the same bytes as the original stream.

Throws a WindowsException on failure.

To learn more, see learn.microsoft.com/windows/win32/api/objidl/nf-objidl-istream-clone.

Implementation

IStream? clone() {
  final ppstm = adaptiveCalloc<VTablePointer>();
  final hr$ = HRESULT(_CloneFn(ptr, ppstm));
  if (hr$.isError) {
    free(ppstm);
    throw WindowsException(hr$);
  }
  final result$ = ppstm.value;
  free(ppstm);
  if (result$.isNull) return null;
  return IStream(result$);
}