Permalink
Browse files

Add (unused) get property functions.

  • Loading branch information...
1 parent 087265e commit edee18ccc74dc1b6c81514f959086e9953399b05 @hanwen committed Apr 26, 2012
Showing with 28 additions and 0 deletions.
  1. +28 −0 mtp.go
View
@@ -214,6 +214,34 @@ func (d *Device) DeleteObject(id uint32) error {
return nil
}
+func (d *Device) GetStringFromObject(id uint32, prop int) (string, error) {
+ mId := C.uint32_t(id)
+ mProp := C.LIBMTP_property_t(prop)
+ result := C.LIBMTP_Get_String_From_Object(d.me(), mId, mProp)
+ return C.GoString(result), d.ErrorStack()
+}
+
+func (d *Device) GetIntFromObject(id uint32, prop int, bits int) (uint64, error) {
+ var result uint64
+ mId := C.uint32_t(id)
+ mProp := C.LIBMTP_property_t(prop)
+ switch (bits) {
+ case 64:
+ result = uint64(C.LIBMTP_Get_u64_From_Object(d.me(), mId, mProp, 0))
+ case 32:
+ result = uint64(C.LIBMTP_Get_u32_From_Object(d.me(), mId, mProp, 0))
+ case 16:
+ result = uint64(C.LIBMTP_Get_u16_From_Object(d.me(), mId, mProp, 0))
+ case 8:
+ result = uint64(C.LIBMTP_Get_u8_From_Object(d.me(), mId, mProp, 0))
+ default:
+ return 0, fmt.Errorf("unsupported bit size %d", bits)
+ }
+
+ return result, d.ErrorStack()
+}
+const DateModified = C.LIBMTP_PROPERTY_DateModified
+
////////////////
// DeviceStorage

0 comments on commit edee18c

Please sign in to comment.