MCPcopy Create free account
hub / github.com/libgit2/git2go / NewReadStream

Method NewReadStream

odb.go:276–295  ·  view source on GitHub ↗

NewReadStream opens a read stream from the ODB. Reading from it will give you the contents of the object.

(id *Oid)

Source from the content-addressed store, hash-verified

274// NewReadStream opens a read stream from the ODB. Reading from it will give you the
275// contents of the object.
276func (v *Odb) NewReadStream(id *Oid) (*OdbReadStream, error) {
277 stream := new(OdbReadStream)
278 var ctype C.git_object_t
279 var csize C.size_t
280
281 runtime.LockOSThread()
282 defer runtime.UnlockOSThread()
283
284 ret := C.git_odb_open_rstream(&stream.ptr, &csize, &ctype, v.ptr, id.toC())
285 runtime.KeepAlive(v)
286 runtime.KeepAlive(id)
287 if ret < 0 {
288 return nil, MakeGitError(ret)
289 }
290
291 stream.Size = uint64(csize)
292 stream.Type = ObjectType(ctype)
293 runtime.SetFinalizer(stream, (*OdbReadStream).Free)
294 return stream, nil
295}
296
297// NewWriteStream opens a write stream to the ODB, which allows you to
298// create a new object in the database. The size and type must be

Callers 1

TestOdbStreamFunction · 0.80

Calls 3

MakeGitErrorFunction · 0.85
ObjectTypeTypeAlias · 0.85
toCMethod · 0.45

Tested by 1

TestOdbStreamFunction · 0.64