當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Device.GetDeviceInfo方法代碼示例

本文整理匯總了Golang中github.com/hanwen/go-mtpfs/mtp.Device.GetDeviceInfo方法的典型用法代碼示例。如果您正苦於以下問題:Golang Device.GetDeviceInfo方法的具體用法?Golang Device.GetDeviceInfo怎麽用?Golang Device.GetDeviceInfo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/hanwen/go-mtpfs/mtp.Device的用法示例。


在下文中一共展示了Device.GetDeviceInfo方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: NewDeviceFSRoot

// DeviceFs is a simple filesystem interface to an MTP device. It
// should be wrapped in a Locking(Raw)FileSystem to make sure it is
// threadsafe.  The file system assumes the device does not touch the
// storage.  Arguments are the opened mtp device and a directory for the
// backing store.
func NewDeviceFSRoot(d *mtp.Device, storages []uint32, options DeviceFsOptions) (nodefs.Node, error) {
	root := rootNode{Node: nodefs.NewDefaultNode()}
	fs := &deviceFS{
		root:    &root,
		dev:     d,
		options: &options,
	}
	root.fs = fs
	fs.storages = storages
	if err := d.GetDeviceInfo(&fs.devInfo); err != nil {
		return nil, err
	}

	if !strings.Contains(fs.devInfo.MTPExtension, "android.com") {
		fs.options.Android = false
	}

	if !options.Android {
		if err := fs.setupClassic(); err != nil {
			return nil, err
		}
	}

	fs.mungeVfat = make(map[uint32]bool)
	for _, sid := range fs.storages {
		var info mtp.StorageInfo
		if err := fs.dev.GetStorageInfo(sid, &info); err != nil {
			return nil, err
		}
		fs.mungeVfat[sid] = info.IsRemovable() && fs.options.RemovableVFat
	}

	return fs.Root(), nil
}
開發者ID:riwsakihelp,項目名稱:go-mtpfs,代碼行數:39,代碼來源:fs.go

示例2: NewDeviceFs

// DeviceFs is a simple filesystem interface to an MTP device. It
// should be wrapped in a Locking(Raw)FileSystem to make sure it is
// threadsafe.  The file system assumes the device does not touch the
// storage.  Arguments are the opened mtp device and a directory for the
// backing store.
func NewDeviceFs(d *mtp.Device, storages []uint32, options DeviceFsOptions) (*DeviceFs, error) {
	root := rootNode{}
	fs := &DeviceFs{root: &root, dev: d, options: &options}
	root.fs = fs
	fs.storages = storages
	err := d.GetDeviceInfo(&fs.devInfo)
	if err != nil {
		return fs, nil
	}

	if !strings.Contains(fs.devInfo.MTPExtension, "android.com") {
		fs.options.Android = false
	}

	if !options.Android {
		err = fs.setupClassic()
		if err != nil {
			return nil, err
		}
	}

	fs.mungeVfat = make(map[uint32]bool)
	for _, sid := range fs.storages {
		var info mtp.StorageInfo
		if err != nil {
			return nil, err
		}

		fs.mungeVfat[sid] = info.IsRemovable() && fs.options.RemovableVFat
	}

	return fs, nil
}
開發者ID:sneezer,項目名稱:go-mtpfs,代碼行數:38,代碼來源:fs.go

示例3: NewDeviceFs

// DeviceFs is a simple filesystem interface to an MTP device. It
// should be wrapped in a Locking(Raw)FileSystem to make sure it is
// threadsafe.  The file system assumes the device does not touch the
// storage.  Arguments are the opened mtp device and a directory for the
// backing store.
func NewDeviceFs(d *mtp.Device, storages []uint32, options DeviceFsOptions) (*DeviceFs, error) {
	o := options

	root := rootNode{}
	fs := &DeviceFs{root: &root, dev: d, options: &o}
	root.fs = fs
	fs.storages = storages
	err := d.GetDeviceInfo(&fs.devInfo)
	if err != nil {
		return fs, nil
	}

	if !strings.Contains(fs.devInfo.MTPExtension, "android.com") {
		return nil, fmt.Errorf("this device has no android.com extensions.")
	}

	for _, sid := range fs.storages {
		var info mtp.StorageInfo
		err := d.GetStorageInfo(sid, &info)
		if err != nil {
			return nil, err
		}
		fs.storageInfos = append(fs.storageInfos, info)
	}
	return fs, nil
}
開發者ID:shining0x55aa,項目名稱:go-mtpfs,代碼行數:31,代碼來源:fs.go


注:本文中的github.com/hanwen/go-mtpfs/mtp.Device.GetDeviceInfo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。