Beispiel #1
0
static int
get_info_func (CameraFilesystem *fs, const char *folder, const char *filename,
	       CameraFileInfo *info, void *data, GPContext *context)
{
	Camera *camera = data;
	int r;
	struct tf_packet reply;
	char *xfolder = strdup (folder);

	backslash (xfolder);

	r = send_cmd_hdd_dir(camera, xfolder, context);
	free (xfolder);
	if(r < GP_OK)
		return r;

	while(0 < get_tf_packet(camera, &reply, context)) {
		switch (get_u32(&reply.cmd)) {
		case DATA_HDD_DIR:
			decode_and_get_info(camera, folder, &reply, filename, info, context);
			send_success(camera,context);
			break;
		case DATA_HDD_DIR_END:
			return GP_OK;
			break;
		case FAIL:
			gp_log (GP_LOG_ERROR, "topfield", "ERROR: Device reports %s\n",
				decode_error(&reply));
			return GP_ERROR_IO;
			break;
		default:
			gp_log (GP_LOG_ERROR, "topfield", "ERROR: Unhandled packet\n");
			return GP_ERROR_IO;
		}
	}
	return GP_OK;
}
Beispiel #2
0
int do_hdd_dir(int fd, char *path)
{
    int r;

    r = send_cmd_hdd_dir(fd, path);
    if(r < 0)
    {
        return -EPROTO;
    }

    while(0 < get_tf_packet(fd, &reply))
    {
        switch (get_u32(&reply.cmd))
        {
            case DATA_HDD_DIR:
                decode_dir(&reply);
                send_success(fd);
                break;

            case DATA_HDD_DIR_END:
                return 0;
                break;

            case FAIL:
                fprintf(stderr, "ERROR: Device reports %s\n",
                        decode_error(&reply));
                return -EPROTO;
                break;

            default:
                fprintf(stderr, "ERROR: Unhandled packet\n");
                return -EPROTO;
        }
    }
    return -EPROTO;
}