static IntPtr svnStreamClose(IntPtr baton) { SvnStreamWrapper sw = AprBaton <SvnStreamWrapper> .Get(baton); if (sw._written) { sw._written = false; sw.Stream.Flush(); } return(IntPtr.Zero); }
static unsafe IntPtr svnStreamMark(IntPtr baton, void **mark, IntPtr pool_ptr) { SvnStreamWrapper sw = AprBaton <SvnStreamWrapper> .Get(baton); using (var pool = new AprPool(pool_ptr, false)) { long *pos = (long *)pool.Alloc(sizeof(long)); *pos = sw.Stream.Position; *mark = (void *)pos; } return(IntPtr.Zero); }
static unsafe IntPtr svnStreamRead(IntPtr baton, sbyte *buffer, ulong *len) { // Subversion: // Handlers are obliged to complete a read or write // to the maximum extent possible; thus, a short read with no // associated error implies the end of the input stream, and a short // write should never occur without an associated error. SvnStreamWrapper sw = AprBaton <SvnStreamWrapper> .Get(baton); byte[] bytes = new byte[(int)*len]; int count = sw.Stream.Read(bytes, 0, (int)*len); Marshal.Copy(bytes, 0, new IntPtr(buffer), count); *len = (ulong)count; return(IntPtr.Zero); }
static unsafe IntPtr svnStreamSeek(IntPtr baton, IntPtr mark) { SvnStreamWrapper sw = AprBaton <SvnStreamWrapper> .Get(baton); long newPos = 0; if (mark != IntPtr.Zero) { newPos = *(long *)mark.ToPointer(); } try { sw.Stream.Position = newPos; } catch (Exception ex) { return(SvnException.CreateExceptionSvnError("Seek stream", ex).__Instance); } return(IntPtr.Zero); }
static unsafe IntPtr svnStreamWrite(IntPtr baton, sbyte *data, ulong *len) { if (*len == 0) { return(IntPtr.Zero); } // Subversion: // Handlers are obliged to complete a read or write // to the maximum extent possible; thus, a short read with no // associated error implies the end of the input stream, and a short // write should never occur without an associated error. SvnStreamWrapper sw = AprBaton <SvnStreamWrapper> .Get(baton); byte[] bytes = new byte[(int)*len]; Marshal.Copy(new IntPtr(data), bytes, 0, bytes.Length); sw.Stream.Write(bytes, 0, bytes.Length); sw._written = true; return(IntPtr.Zero); }