2013-03-05 13:53:04 -06:00
|
|
|
package git
|
|
|
|
|
|
|
|
/*
|
|
|
|
#include <git2.h>
|
|
|
|
#include <git2/errors.h>
|
|
|
|
*/
|
|
|
|
import "C"
|
|
|
|
import (
|
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Blob struct {
|
2013-04-17 17:54:46 -05:00
|
|
|
gitObject
|
2013-04-16 16:04:35 -05:00
|
|
|
}
|
|
|
|
|
2013-04-17 17:54:46 -05:00
|
|
|
func (v Blob) Size() int64 {
|
2013-03-06 16:59:33 -06:00
|
|
|
return int64(C.git_blob_rawsize(v.ptr))
|
|
|
|
}
|
|
|
|
|
2013-04-17 17:54:46 -05:00
|
|
|
func (v Blob) Contents() []byte {
|
2013-03-05 13:53:04 -06:00
|
|
|
size := C.int(C.git_blob_rawsize(v.ptr))
|
|
|
|
buffer := unsafe.Pointer(C.git_blob_rawcontent(v.ptr))
|
|
|
|
return C.GoBytes(buffer, size)
|
|
|
|
}
|
|
|
|
|