예제 #1
0
            private static unsafe int Write(
                IntPtr backend,
                ref GitOid oid,
                IntPtr data,
                UIntPtr len,
                GitObjectType type)
            {
                long length = ConverToLong(len);

                OdbBackend odbBackend = MarshalOdbBackend(backend);

                if (odbBackend == null)
                {
                    return((int)GitErrorCode.Error);
                }

                try
                {
                    using (var stream = new UnmanagedMemoryStream((byte *)data, length))
                    {
                        return(odbBackend.Write(new ObjectId(oid), stream, length, type.ToObjectType()));
                    }
                }
                catch (Exception ex)
                {
                    Proxy.giterr_set_str(GitErrorCategory.Odb, ex);
                    return((int)GitErrorCode.Error);
                }
            }
예제 #2
0
            private static int WriteStream(
                out IntPtr stream_out,
                IntPtr backend,
                long len,
                GitObjectType type)
            {
                stream_out = IntPtr.Zero;

                OdbBackend odbBackend = MarshalOdbBackend(backend);

                if (odbBackend == null)
                {
                    return((int)GitErrorCode.Error);
                }

                ObjectType objectType = type.ToObjectType();

                try
                {
                    OdbBackendStream stream;
                    int toReturn = odbBackend.WriteStream(len, objectType, out stream);

                    if (toReturn == 0)
                    {
                        stream_out = stream.GitOdbBackendStreamPointer;
                    }

                    return(toReturn);
                }
                catch (Exception ex)
                {
                    Proxy.giterr_set_str(GitErrorCategory.Odb, ex);
                    return((int)GitErrorCode.Error);
                }
            }
예제 #3
0
            private static unsafe int Write(
                ref GitOid oid,
                IntPtr backend,
                IntPtr data,
                UIntPtr len,
                GitObjectType type)
            {
                OdbBackend odbBackend = GCHandle.FromIntPtr(Marshal.ReadIntPtr(backend, GitOdbBackend.GCHandleOffset)).Target as OdbBackend;

                ObjectType objectType = type.ToObjectType();

                if (odbBackend != null &&
                    len.ToUInt64() < long.MaxValue)
                {
                    try
                    {
                        using (UnmanagedMemoryStream stream = new UnmanagedMemoryStream((byte *)data, (long)len.ToUInt64()))
                        {
                            byte[] finalOid;

                            int toReturn = odbBackend.Write(oid.Id, stream, (long)len.ToUInt64(), objectType, out finalOid);

                            if (0 == toReturn)
                            {
                                oid.Id = finalOid;
                            }

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

                return((int)GitErrorCode.Error);
            }
예제 #4
0
            private static int WriteStream(
                out IntPtr stream_out,
                IntPtr backend,
                UIntPtr length,
                GitObjectType type)
            {
                stream_out = IntPtr.Zero;

                OdbBackend odbBackend = GCHandle.FromIntPtr(Marshal.ReadIntPtr(backend, GitOdbBackend.GCHandleOffset)).Target as OdbBackend;

                ObjectType objectType = type.ToObjectType();

                if (odbBackend != null &&
                    length.ToUInt64() < long.MaxValue)
                {
                    OdbBackendStream stream;

                    try
                    {
                        int toReturn = odbBackend.WriteStream((long)length.ToUInt64(), objectType, out stream);

                        if (0 == toReturn)
                        {
                            stream_out = stream.GitOdbBackendStreamPointer;
                        }

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

                return((int)GitErrorCode.Error);
            }
예제 #5
0
            private static int WriteStream(
                out IntPtr stream_out,
                IntPtr backend,
                UIntPtr len,
                GitObjectType type)
            {
                stream_out = IntPtr.Zero;

                long length = ConverToLong(len);

                OdbBackend odbBackend = MarshalOdbBackend(backend);
                if (odbBackend == null)
                {
                    return (int)GitErrorCode.Error;
                }

                ObjectType objectType = type.ToObjectType();

                try
                {
                    OdbBackendStream stream;
                    int toReturn = odbBackend.WriteStream(length, objectType, out stream);

                    if (toReturn == 0)
                    {
                        stream_out = stream.GitOdbBackendStreamPointer;
                    }

                    return toReturn;
                }
                catch (Exception ex)
                {
                    Proxy.giterr_set_str(GitErrorCategory.Odb, ex);
                    return (int)GitErrorCode.Error;
                }
            }
예제 #6
0
            private static unsafe int Write(
                IntPtr backend,
                ref GitOid oid,
                IntPtr data,
                UIntPtr len,
                GitObjectType type)
            {
                long length = ConverToLong(len);

                OdbBackend odbBackend = MarshalOdbBackend(backend);
                if (odbBackend == null)
                {
                    return (int)GitErrorCode.Error;
                }

                try
                {
                    using (var stream = new UnmanagedMemoryStream((byte*)data, length))
                    {
                        return odbBackend.Write(new ObjectId(oid), stream, length, type.ToObjectType());
                    }
                }
                catch (Exception ex)
                {
                    Proxy.giterr_set_str(GitErrorCategory.Odb, ex);
                    return (int)GitErrorCode.Error;
                }
            }
예제 #7
0
            private static int WriteStream(
                out IntPtr stream_out,
                IntPtr backend,
                UIntPtr length,
                GitObjectType type)
            {
                stream_out = IntPtr.Zero;

                OdbBackend odbBackend = GCHandle.FromIntPtr(Marshal.ReadIntPtr(backend, GitOdbBackend.GCHandleOffset)).Target as OdbBackend;

                ObjectType objectType = type.ToObjectType();

                if (odbBackend != null &&
                    length.ToUInt64() < long.MaxValue)
                {
                    OdbBackendStream stream;

                    try
                    {
                        int toReturn = odbBackend.WriteStream((long)length.ToUInt64(), objectType, out stream);

                        if (0 == toReturn)
                        {
                            stream_out = stream.GitOdbBackendStreamPointer;
                        }

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

                return (int)GitErrorCode.Error;
            }
예제 #8
0
            private static unsafe int Write(
                ref GitOid oid,
                IntPtr backend,
                IntPtr data,
                UIntPtr len,
                GitObjectType type)
            {
                OdbBackend odbBackend = GCHandle.FromIntPtr(Marshal.ReadIntPtr(backend, GitOdbBackend.GCHandleOffset)).Target as OdbBackend;

                ObjectType objectType = type.ToObjectType();

                if (odbBackend != null &&
                    len.ToUInt64() < long.MaxValue)
                {
                    try
                    {
                        using (UnmanagedMemoryStream stream = new UnmanagedMemoryStream((byte*)data, (long)len.ToUInt64()))
                        {
                            byte[] finalOid;

                            int toReturn = odbBackend.Write(oid.Id, stream, (long)len.ToUInt64(), objectType, out finalOid);

                            if (0 == toReturn)
                            {
                                oid.Id = finalOid;
                            }

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

                return (int)GitErrorCode.Error;
            }