Home |
Media Transfer Protocol Class Driver Function USBMTPGetFileProperty Function USBMTPSetFileProperty Function USBMTPPutFile |
Function USBMTPPutFileUSBMTPPutFile creates a directory or sends a file to a USB MTP device: typedef void (RTTAPI * USBMTPDataCallback) (void * P, void * Data, UINT Len); int USBMTPPutFile(int Dev, int Store, USBMTPHandle DirHandle, USBMTPFileInfo * Info, void * P, USBMTPDataCallback Callback); ParametersDevIndex of the MTP device. This value should be in range 0 .. RTUSBMTPConfig.MaxDevices - 1. StoreZero-based index of the storage device. Function USBMTPGetDevInfo can determine how many storage devices are available. DirHandleHandle of the directory to receive the new file or directory. For the root directory, use value USBMTP_ROOTDIR. InfoPointer to a structure with information about the new file. This parameter may not be NULL! Please see below for further information. PAn arbitrary value that will be passed on to parameter Callback. CallbackA pointer to a function to be called by USBMTPPutFile to retrieve the file's data from the application. This parameter may be NULL to create a directory. return valueIf successful, a value >= RTU_SUCCESS is returned, otherwise, a negative error code. Parameter *Info must contain at least the file's size in ObjectCompressedSize and its name in Filename. If a directory is to be created, ObjectCompressedSize must be 0 and ObjectFormat must be USBMTP_FORMAT_FOLDER. All other fields of *Info may (but do not have to) be 0. If ObjectFormat is 0, this function will attempt to determine a format based on the file name extension, if any. All format values are listed in include file Include\Rtusb.h (all USBMTP_FORMAT_... constants). If the format cannot be determined from the file name, USBMTP_FORMAT_UNDEF is used. USBMTP_FORMAT_UNDEF is also recommended for all file formats not supported by the MTP device (e.g., .rtb, .dlm, .exe, etc files). This function calls the function specified in parameter Callback with the parameter P passed to USBMTPPutFile, a pointer to its internal buffer, and the number of free bytes in the buffer. The callback should typically read the data from a local file or produce the data in some other way. USBMTPPutFile then sends the data to the MTP device. The callback is called repeatedly until all of the file's data has been transferred (based on Info->ObjectCompressedSize). Functions Put and MD of demo program MTPDemo shows how this function is used. Function USBMTPSetEventCallback
|