private static int CopyToImpl(IntPtr thisPtr, IntPtr streamPointer, long numberOfBytes, out long numberOfBytesRead, out long numberOfBytesWritten) { numberOfBytesRead = 0; numberOfBytesWritten = 0; try { IStreamShadow shadow = ToShadow <IStreamShadow>(thisPtr); IStream callback = ((IStream)shadow.Callback); numberOfBytesRead = callback.CopyTo(new ComStream(streamPointer), numberOfBytes, out numberOfBytesWritten); } catch (Exception exception) { return((int)Result.GetResultFromException(exception)); } return(Result.Ok.Code); }
private static Result StatImpl(IntPtr thisPtr, ref StorageStatistics.__Native statisticsPtr, StorageStatisticsFlags flags) { try { IStreamShadow shadow = ToShadow <IStreamShadow>(thisPtr); IStream callback = ((IStream)shadow.Callback); StorageStatistics statistics = callback.GetStatistics(flags); statistics.__MarshalTo(ref statisticsPtr); } catch (SharpGenException exception) { return(exception.ResultCode); } catch (Exception) { return(Result.Fail.Code); } return(Result.Ok); }
private static Result UnlockRegionImpl(IntPtr thisPtr, long offset, long numberOfBytes, LockType lockType) { Result result = Result.Ok; try { IStreamShadow shadow = ToShadow <IStreamShadow>(thisPtr); IStream callback = ((IStream)shadow.Callback); callback.UnlockRegion(offset, numberOfBytes, lockType); } catch (SharpGenException exception) { result = exception.ResultCode; } catch (Exception) { result = Result.Fail.Code; } return(result); }
private static Result RevertImpl(IntPtr thisPtr) { Result result = Result.Ok; try { IStreamShadow shadow = ToShadow <IStreamShadow>(thisPtr); IStream callback = ((IStream)shadow.Callback); callback.Revert(); } catch (SharpGenException exception) { result = exception.ResultCode; } catch (Exception) { result = Result.Fail.Code; } return(result); }
private static unsafe int SeekImpl(IntPtr thisPtr, long offset, SeekOrigin origin, IntPtr newPosition) { try { IStreamShadow shadow = ToShadow <IStreamShadow>(thisPtr); IStream callback = ((IStream)shadow.Callback); long position = callback.Seek(offset, origin); // pointer can be null, so we need to test it if (newPosition != IntPtr.Zero) { *(long *)newPosition = position; } } catch (Exception exception) { return((int)Result.GetResultFromException(exception)); } return(Result.Ok.Code); }
private static Result CloneImpl(IntPtr thisPtr, out IntPtr streamPointer) { streamPointer = IntPtr.Zero; var result = Result.Ok; try { var shadow = ToShadow <IStreamShadow>(thisPtr); var callback = ((IStream)shadow.Callback); var clone = callback.Clone(); streamPointer = IStreamShadow.ToIntPtr(clone); } catch (SharpGenException exception) { result = exception.ResultCode; } catch (Exception) { result = Result.Fail.Code; } return(result); }