示例#1
0
func newGphotoList() (*C.CameraList, error) {
	var gpFileList *C.CameraList
	if retval := C.gp_list_new((**C.CameraList)(unsafe.Pointer(&gpFileList))); retval != gpOk {
		return nil, fmt.Errorf("Could not create a list, error code %v", retval)
	}
	return gpFileList, nil
}
示例#2
0
func (c *Camera) ListFiles(folder string) ([]string, int) {
	if folder == "" {
		folder = "/"
	}

	if !strings.HasSuffix(folder, "/") {
		folder = folder + "/"
	}

	var cameraList *C.CameraList
	C.gp_list_new(&cameraList)
	defer C.free(unsafe.Pointer(cameraList))

	cFolder := C.CString(folder)
	defer C.free(unsafe.Pointer(cFolder))

	err := C.gp_camera_folder_list_files(c.camera, cFolder, cameraList, c.context)
	fileNameMap, _ := cameraListToMap(cameraList)

	names := make([]string, len(fileNameMap))
	i := 0
	for key, _ := range fileNameMap {
		names[i] = key
		i += 1
	}

	return names, int(err)
}