files(3) | libmtp | files(3) |
libmtp - files
#define LIBMTP_FILES_AND_FOLDERS_ROOT 0xffffffff
typedef void(* LIBMTP_event_cb_fn) (int, LIBMTP_event_t,
uint32_t, void *)
LIBMTP_file_t * LIBMTP_new_file_t (void)
void LIBMTP_destroy_file_t (LIBMTP_file_t *)
char const * LIBMTP_Get_Filetype_Description (LIBMTP_filetype_t)
LIBMTP_file_t * LIBMTP_Get_Filelisting
(LIBMTP_mtpdevice_t *)
LIBMTP_file_t * LIBMTP_Get_Filelisting_With_Callback
(LIBMTP_mtpdevice_t *, LIBMTP_progressfunc_t const, void const
*const)
LIBMTP_file_t * LIBMTP_Get_Files_And_Folders
(LIBMTP_mtpdevice_t *, uint32_t const, uint32_t const)
LIBMTP_file_t * LIBMTP_Get_Filemetadata
(LIBMTP_mtpdevice_t *, uint32_t const)
int LIBMTP_Get_File_To_File (LIBMTP_mtpdevice_t *, uint32_t,
char const *const, LIBMTP_progressfunc_t const, void const *const)
int LIBMTP_Get_File_To_File_Descriptor (LIBMTP_mtpdevice_t *,
uint32_t const, int const, LIBMTP_progressfunc_t const, void const
*const)
int LIBMTP_Get_File_To_Handler (LIBMTP_mtpdevice_t *, uint32_t
const, MTPDataPutFunc, void *, LIBMTP_progressfunc_t const,
void const *const)
int LIBMTP_Send_File_From_File (LIBMTP_mtpdevice_t *, char const
*const, LIBMTP_file_t *const, LIBMTP_progressfunc_t const,
void const *const)
int LIBMTP_Send_File_From_File_Descriptor (LIBMTP_mtpdevice_t *,
int const, LIBMTP_file_t *const, LIBMTP_progressfunc_t const,
void const *const)
int LIBMTP_Send_File_From_Handler (LIBMTP_mtpdevice_t *,
MTPDataGetFunc, void *, LIBMTP_file_t *const,
LIBMTP_progressfunc_t const, void const *const)
int LIBMTP_Set_File_Name (LIBMTP_mtpdevice_t *,
LIBMTP_file_t *, const char *)
LIBMTP_filesampledata_t * LIBMTP_new_filesampledata_t (void)
void LIBMTP_destroy_filesampledata_t (LIBMTP_filesampledata_t *)
int LIBMTP_Get_Representative_Sample_Format (LIBMTP_mtpdevice_t
*, LIBMTP_filetype_t const, LIBMTP_filesampledata_t **)
int LIBMTP_Send_Representative_Sample (LIBMTP_mtpdevice_t *,
uint32_t const, LIBMTP_filesampledata_t *)
int LIBMTP_Get_Representative_Sample (LIBMTP_mtpdevice_t *,
uint32_t const, LIBMTP_filesampledata_t *)
int LIBMTP_Get_Thumbnail (LIBMTP_mtpdevice_t *, uint32_t const,
unsigned char **data, unsigned int *size)
int LIBMTP_Read_Event (LIBMTP_mtpdevice_t *, LIBMTP_event_t *,
uint32_t *)
int LIBMTP_Read_Event_Async (LIBMTP_mtpdevice_t *,
LIBMTP_event_cb_fn, void *)
int LIBMTP_Handle_Events_Timeout_Completed (struct timeval *, int *)
This destroys a file metadata structure and deallocates the memory used by it, including any strings. Never use a file metadata structure again after calling this function on it.
Parameters
See also
References LIBMTP_file_struct::filename.
This destroys a file sample metadata type.
Parameters
References LIBMTP_filesampledata_struct::data.
This gets a file off the device to a local file identified by a filename.
Parameters
Returns
See also
Referenced by LIBMTP_Get_Track_To_File().
This gets a file off the device to a file identified by a file descriptor.
This function can potentially be used for streaming files off the device for playback or broadcast for example, by downloading the file into a stream sink e.g. a socket.
Parameters
Returns
See also
References LIBMTP_Get_Filemetadata(), LIBMTP_mtpdevice_struct::params, and LIBMTP_mtpdevice_struct::usbinfo.
Referenced by LIBMTP_Get_Track_To_File_Descriptor().
This gets a file off the device and calls put_func with chunks of data
Parameters
Returns
References LIBMTP_Get_Filemetadata(), LIBMTP_mtpdevice_struct::params, and LIBMTP_mtpdevice_struct::usbinfo.
Referenced by LIBMTP_Get_Track_To_Handler().
THIS FUNCTION IS DEPRECATED. PLEASE UPDATE YOUR CODE IN ORDER NOT TO USE IT.
See also
References LIBMTP_Get_Filelisting_With_Callback().
This returns a long list of all files available on the current MTP device. Folders will not be returned, but abstract entities like playlists and albums will show up as 'files'. Typical usage:
LIBMTP_file_t *filelist; filelist = LIBMTP_Get_Filelisting_With_Callback(device, callback, data); while (filelist != NULL) {
LIBMTP_file_t *tmp;
// Do something on each element in the list here...
tmp = filelist;
filelist = filelist->next;
LIBMTP_destroy_file_t(tmp); }
If you want to group your file listing by storage (per storage unit) or arrange files into folders, you must dereference the storage_id and/or parent_id field of the returned LIBMTP_file_t struct. To arrange by folders or files you typically have to create the proper trees by calls to LIBMTP_Get_Storage() and/or LIBMTP_Get_Folder_List() first.
Parameters
Returns
See also
References LIBMTP_mtpdevice_struct::params.
Referenced by LIBMTP_Get_Filelisting().
This function retrieves the metadata for a single file off the device.
Do not call this function repeatedly! The file handles are linearly searched O(n) and the call may involve (slow) USB traffic, so use LIBMTP_Get_Filelisting() and cache the file, preferably as an efficient data structure such as a hash list.
Incidentally this function will return metadata for a folder (association) as well, but this is not a proper use of it, it is intended for file manipulation, not folder manipulation.
Parameters
Returns
See also
References LIBMTP_mtpdevice_struct::cached, and LIBMTP_mtpdevice_struct::params.
Referenced by LIBMTP_Get_File_To_File_Descriptor(), LIBMTP_Get_File_To_Handler(), and LIBMTP_Set_Object_Filename().
This function retrieves the contents of a certain folder with id parent on a certain storage on a certain device. The result contains both files and folders. The device used with this operations must have been opened with LIBMTP_Open_Raw_Device_Uncached() or it will fail.
NOTE: the request will always perform I/O with the device.
Parameters
References LIBMTP_mtpdevice_struct::cached, and LIBMTP_mtpdevice_struct::params.
This helper function returns a textual description for a libmtp file type to be used in dialog boxes etc.
Parameters
Returns
This routine gets representative sample data for an object. This uses the RepresentativeSampleData property of the album, if the device supports it.
Parameters
Returns
See also
LIBMTP_Get_Representative_Sample_Format()
LIBMTP_Create_New_Album()
References LIBMTP_mtpdevice_struct::params.
This routine figures out whether a certain filetype supports representative samples (small thumbnail images) or not. This typically applies to JPEG files, MP3 files and Album abstract playlists, but in theory any filetype could support representative samples.
Parameters
Returns
See also
LIBMTP_Create_New_Album()
References LIBMTP_mtpdevice_struct::params.
Retrieve the thumbnail for a file.
Parameters
Returns
References LIBMTP_mtpdevice_struct::params.
Trivial wrapper around the most generic libusb method for polling for events. Can be used to drive asynchronous event detection.
This creates a new file metadata structure and allocates memory for it. Notice that if you add strings to this structure they will be freed by the corresponding LIBMTP_destroy_file_t operation later, so be careful of using strdup() when assigning strings, e.g.:
LIBMTP_file_t *file = LIBMTP_new_file_t(); file->filename = strdup(namestr); .... LIBMTP_destroy_file_t(file);
Returns
See also
References LIBMTP_file_struct::filename.
This creates a new sample data metadata structure and allocates memory for it. Notice that if you add strings to this structure they will be freed by the corresponding LIBMTP_destroy_sampledata_t operation later, so be careful of using strdup() when assigning strings.
Returns
See also
References LIBMTP_filesampledata_struct::height.
To read events sent by the device, repeatedly call this function from a secondary thread until the return value is < 0.
Parameters
Returns
References LIBMTP_mtpdevice_struct::params.
This function reads events sent by the device, in a non-blocking manner. The callback function will be called when an event is received, but for the function to make progress, polling must take place, using LIBMTP_Handle_Events_Timeout_Completed.
After an event is received, this function should be called again to listen for the next event.
For now, this non-blocking mechanism only works with libusb-1.0, and not any of the other usb library backends. Attempting to call this method with another backend will always return an error.
Parameters
Returns
This function sends a local file to an MTP device. A filename and a set of metadata must be given as input.
Parameters
callback a progress indicator function or NULL to ignore.
data a user-defined pointer that is passed along to the progress
function in order to pass along some user defined data to the progress
updates. If not used, set this to NULL.
Returns
See also
LIBMTP_Delete_Object()
This function sends a generic file from a file descriptor to an MTP device. A filename and a set of metadata must be given as input.
This can potentially be used for sending in a stream of unknown length. Send music files with LIBMTP_Send_Track_From_File_Descriptor()
Parameters
callback a progress indicator function or NULL to ignore.
data a user-defined pointer that is passed along to the progress
function in order to pass along some user defined data to the progress
updates. If not used, set this to NULL.
Returns
See also
LIBMTP_Send_Track_From_File_Descriptor()
LIBMTP_Delete_Object()
References LIBMTP_mtpdevice_struct::params, and LIBMTP_mtpdevice_struct::usbinfo.
This function sends a generic file from a handler function to an MTP device. A filename and a set of metadata must be given as input.
This can potentially be used for sending in a stream of unknown length. Send music files with LIBMTP_Send_Track_From_Handler()
Parameters
callback a progress indicator function or NULL to ignore.
data a user-defined pointer that is passed along to the progress
function in order to pass along some user defined data to the progress
updates. If not used, set this to NULL.
Returns
See also
LIBMTP_Send_Track_From_File_Descriptor()
LIBMTP_Delete_Object()
References LIBMTP_mtpdevice_struct::params, and LIBMTP_mtpdevice_struct::usbinfo.
This routine sends representative sample data for an object. This uses the RepresentativeSampleData property of the album, if the device supports it. The data should be of a format acceptable to the player (for iRiver and Creative, this seems to be JPEG) and must not be too large. (for a Creative, max seems to be about 20KB.) Check by calling LIBMTP_Get_Representative_Sample_Format() to get maximum size, dimensions, etc..
Parameters
Returns
See also
LIBMTP_Get_Representative_Sample_Format()
LIBMTP_Create_New_Album()
References LIBMTP_mtpdevice_struct::params, and LIBMTP_mtpdevice_struct::usbinfo.
This function renames a single file. This simply means that the PTP_OPC_ObjectFileName property is updated, if this is supported by the device.
Parameters
Returns
Generated automatically by Doxygen for libmtp from the source code.
Fri Jul 22 2022 | Version 1.1.20 |