예제 #1
0
            private static int FinalizeWrite(
                out GitOid oid_p,
                IntPtr stream)
            {
                oid_p = default(GitOid);

                OdbBackendStream odbBackendStream = GCHandle.FromIntPtr(Marshal.ReadIntPtr(stream, GitOdbBackendStream.GCHandleOffset)).Target as OdbBackendStream;

                if (odbBackendStream != null)
                {
                    byte[] computedObjectId;

                    try
                    {
                        int toReturn = odbBackendStream.FinalizeWrite(out computedObjectId);

                        if (0 == toReturn)
                        {
                            oid_p.Id = computedObjectId;
                        }

                        return(toReturn);
                    }
                    catch (Exception ex)
                    {
                        Proxy.giterr_set_str(GitErrorCategory.Odb, ex);
                    }
                }

                return((int)GitErrorCode.Error);
            }
            private static unsafe int Write(
                IntPtr stream,
                IntPtr buffer,
                UIntPtr len)
            {
                OdbBackendStream odbBackendStream = GCHandle.FromIntPtr(Marshal.ReadIntPtr(stream, GitOdbBackendStream.GCHandleOffset)).Target as OdbBackendStream;

                if (odbBackendStream != null)
                {
                    long length = OdbBackend.ConverToLong(len);

                    using (UnmanagedMemoryStream dataStream = new UnmanagedMemoryStream((byte *)buffer, length))
                    {
                        try
                        {
                            return(odbBackendStream.Write(dataStream, length));
                        }
                        catch (Exception ex)
                        {
                            Proxy.giterr_set_str(GitErrorCategory.Odb, ex);
                        }
                    }
                }

                return((int)GitErrorCode.Error);
            }
예제 #3
0
            private unsafe static int Read(
                IntPtr stream,
                IntPtr buffer,
                UIntPtr len)
            {
                OdbBackendStream odbBackendStream = GCHandle.FromIntPtr(Marshal.ReadIntPtr(stream, GitOdbBackendStream.GCHandleOffset)).Target as OdbBackendStream;

                if (odbBackendStream != null &&
                    len.ToUInt64() < long.MaxValue)
                {
                    using (UnmanagedMemoryStream memoryStream = new UnmanagedMemoryStream((byte *)buffer, 0, (long)len.ToUInt64(), FileAccess.ReadWrite))
                    {
                        try
                        {
                            return(odbBackendStream.Read(memoryStream, (long)len.ToUInt64()));
                        }
                        catch (Exception ex)
                        {
                            Proxy.giterr_set_str(GitErrorCategory.Odb, ex);
                        }
                    }
                }

                return((int)GitErrorCode.Error);
            }
예제 #4
0
            private static void Free(IntPtr stream)
            {
                OdbBackendStream odbBackendStream = GCHandle.FromIntPtr(Marshal.ReadIntPtr(stream, GitOdbBackendStream.GCHandleOffset)).Target as OdbBackendStream;

                if (odbBackendStream != null)
                {
                    try
                    {
                        odbBackendStream.Dispose();
                    }
                    catch (Exception ex)
                    {
                        Proxy.git_error_set_str(GitErrorCategory.Odb, ex);
                    }
                }
            }
예제 #5
0
            private static int FinalizeWrite(IntPtr stream, ref GitOid oid)
            {
                OdbBackendStream odbBackendStream = GCHandle.FromIntPtr(Marshal.ReadIntPtr(stream, GitOdbBackendStream.GCHandleOffset)).Target as OdbBackendStream;

                if (odbBackendStream != null)
                {
                    try
                    {
                        return(odbBackendStream.FinalizeWrite(new ObjectId(oid)));
                    }
                    catch (Exception ex)
                    {
                        Proxy.git_error_set_str(GitErrorCategory.Odb, ex);
                    }
                }

                return((int)GitErrorCode.Error);
            }
예제 #6
0
 /// <summary>
 ///   Requests that this backend write an object to the backing store. Returns a stream so that the caller can write
 ///   the data in chunks.
 /// </summary>
 public abstract int WriteStream(long length,
     ObjectType objectType,
     out OdbBackendStream stream);
예제 #7
0
 /// <summary>
 ///   Requests that this backend read an object. Returns a stream so that the caller can read the data in chunks.
 /// </summary>
 public abstract int ReadStream(byte[] oid,
     out OdbBackendStream stream);
예제 #8
0
 /// <summary>
 /// Requests that this backend write an object to the backing store. Returns a stream so that the caller can write
 /// the data in chunks.
 /// </summary>
 public abstract int WriteStream(
     long length,
     ObjectType objectType,
     out OdbBackendStream stream);
예제 #9
0
 /// <summary>
 /// Requests that this backend read an object. Returns a stream so that the caller can read the data in chunks.
 /// </summary>
 public abstract int ReadStream(
     ObjectId id,
     out OdbBackendStream stream);
예제 #10
0
 /// <summary>
 /// Requests that this backend read an object. Returns a stream so that the caller can read the data in chunks.
 /// </summary>
 public abstract int ReadStream(
     ObjectId id,
     out OdbBackendStream stream);
예제 #11
0
 /// <summary>
 ///   Requests that this backend read an object. Returns a stream so that the caller can read the data in chunks.
 /// </summary>
 public abstract int ReadStream(byte[] oid,
                                out OdbBackendStream stream);