NewReadStream opens a read stream from the ODB. Reading from it will give you the contents of the object.
(id *Oid)
| 274 | // NewReadStream opens a read stream from the ODB. Reading from it will give you the |
| 275 | // contents of the object. |
| 276 | func (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 |