files(3)
π files(3) π
okay bestie, so files(3) is your file management API β like, the whole Library Functions Manual vibes, and this is where you learn to poke at files on an MTP device. it's giving "backstage pass to the filesystem" honestly. we're doing this in parts so buckle up π
β¨ SYNOPSIS β¨
π¦ Macros
#define LIBMTP_FILES_AND_FOLDERS_ROOT 0xffffffff
that's your magic "root" number, iykyk π
π¦ Typedefs
typedef void(* LIBMTP_event_cb_fn) (int, LIBMTP_event_t, uint32_t, void
*)
π¦ Functions
like, the whole cast of characters, fr fr:
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)
int LIBMTP_Get_Children (LIBMTP_mtpdevice_t *, uint32_t const, uint32_t
const, uint32_t **)
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 *)
πΈ Detailed Description πΈ
bestie the actual deets live down in the function docs below β that's where all the main character energy is π
π Function Documentation π
π void LIBMTP_destroy_file_t (LIBMTP_file_t * file)
this one destroys a file metadata structure π β like, deallocates all the memory it was using, including any strings. and bestie, listen to me: never use a file metadata structure again after calling this function on it. it's gone. gone gone. no take-backs, no "wait actuallyβ". periodt.
Parameters
fileβ the file metadata to destroy.
See also
LIBMTP_new_file_t()
References LIBMTP_file_struct::filename.
Referenced by LIBMTP_Get_File_To_File_Descriptor(), LIBMTP_Get_File_To_Handler(), LIBMTP_Send_File_From_File_Descriptor(), and LIBMTP_Send_File_From_Handler().
π void LIBMTP_destroy_filesampledata_t (LIBMTP_filesampledata_t * sample)
this one destroys a file sample metadata type. same vibe, smaller struct π«Ά
Parameters
sampleβ the file sample metadata to be destroyed.
References LIBMTP_filesampledata_struct::data.
π int LIBMTP_Get_Children (LIBMTP_mtpdevice_t * device, uint32_t const storage, uint32_t const parent, uint32_t ** out)
okay so this function pulls the list of ids of files and folders inside a certain folder with id parent, on a certain storage, on a certain device. very "give me the children" of it all π
β οΈ heads up: the device used with this operation must have been opened with LIBMTP_Open_Raw_Device_Uncached() or it will fail. no cap, it will just fail on you.
NOTE: the request will always perform I/O with the device. like, always always.
Parameters
deviceβ a pointer to the MTP device to report info from.storageβ a storage on the device to report info from. If0is passed in, the files for the given parent will be searched across all available storages.parentβ the parent folder id.outβ the pointer where the array of ids is returned. It is set only when the returned value> 0. The caller takes the ownership of the array and has tofree()it. so like, that's your array now, bestie, you clean it up π§Ή
Returns the length of the returned array or -1 in case of failure.
References LIBMTP_mtpdevice_struct::cached, and LIBMTP_mtpdevice_struct::params.
π int LIBMTP_Get_File_To_File (LIBMTP_mtpdevice_t * device, uint32_t const id, char const *const path, LIBMTP_progressfunc_t const callback, void const *const data)
this gets a file off the device and into a local file identified by a filename. literally pulling it out of the device's hands and putting it on your disk π
Parameters
deviceβ a pointer to the device to get the track from.idβ the file ID of the file to retrieve.pathβ a filename to use for the retrieved file.callbackβ a progress indicator function orNULLto 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 toNULL.
Returns 0 if the transfer was successful, any other value means failure. slay if it's zero, sad if it's not π
See also
LIBMTP_Get_File_To_File_Descriptor()
References LIBMTP_Get_File_To_File_Descriptor().
Referenced by LIBMTP_Get_Track_To_File().
π int LIBMTP_Get_File_To_File_Descriptor (LIBMTP_mtpdevice_t * device, uint32_t const id, int const fd, LIBMTP_progressfunc_t const callback, void const *const data)
gets a file off the device into a file identified by a file descriptor this time. glow up from the last one β¨
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. it's giving "live stream era" π₯
Parameters
deviceβ a pointer to the device to get the file from.idβ the file ID of the file to retrieve.fdβ a local file descriptor to write the file to.callbackβ a progress indicator function orNULLto 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 toNULL.
Returns 0 if the transfer was successful, any other value means failure.
See also
LIBMTP_Get_File_To_File()
References _PTP_USB::callback_active, LIBMTP_file_struct::filesize, LIBMTP_file_struct::filetype, LIBMTP_destroy_file_t(), LIBMTP_Get_Filemetadata(), LIBMTP_mtpdevice_struct::params, and LIBMTP_mtpdevice_struct::usbinfo.
Referenced by LIBMTP_Get_File_To_File(), and LIBMTP_Get_Track_To_File_Descriptor().
π int LIBMTP_Get_File_To_Handler (LIBMTP_mtpdevice_t * device, uint32_t const id, MTPDataPutFunc put_func, void * priv, LIBMTP_progressfunc_t const callback, void const *const data)
gets a file off the device and calls put_func with chunks of data. chunk by chunk by chunk, like a little data conga line π
Parameters
deviceβ a pointer to the device to get the file from.idβ the file ID of the file to retrieve.put_funcβ the function to call when we have data.privβ the user-defined pointer that is passed toput_func.callbackβ a progress indicator function orNULLto 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 toNULL.
Returns 0 if the transfer was successful, any other value means failure.
References _PTP_USB::callback_active, LIBMTP_file_struct::filesize, LIBMTP_file_struct::filetype, LIBMTP_destroy_file_t(), LIBMTP_Get_Filemetadata(), LIBMTP_mtpdevice_struct::params, and LIBMTP_mtpdevice_struct::usbinfo.
Referenced by LIBMTP_Get_Track_To_Handler().
π LIBMTP_file_t * LIBMTP_Get_Filelisting (LIBMTP_mtpdevice_t * device)
π¨ THIS FUNCTION IS DEPRECATED. PLEASE UPDATE YOUR CODE IN ORDER NOT TO USE IT. π¨
like, i'm not mad, i'm just disappointed. go use the shiny one instead π
See also
LIBMTP_Get_Filelisting_With_Callback()
References LIBMTP_Get_Filelisting_With_Callback().
π LIBMTP_file_t * LIBMTP_Get_Filelisting_With_Callback (LIBMTP_mtpdevice_t * device, LIBMTP_progressfunc_t const callback, void const *const data)
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" β they're cosplaying as files, iconic honestly π
typical usage, bestie, copy this vibe:
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. build the tree, then decorate it π
Parameters
deviceβ a pointer to the device to get the file listing for.callbackβ a function to be called during the tracklisting retrieveal for displaying progress bars etc, orNULLif you don't want any callbacks.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 toNULL.
Returns a list of files that can be followed using the next field of the LIBMTP_file_t data structure. Each of the metadata tags must be freed after use, and may contain only partial metadata information, i.e. one or several fields may be NULL or 0. so like... don't trust every field to be filled in, fr fr π
See also
LIBMTP_Get_Filemetadata()
References LIBMTP_file_struct::next, and LIBMTP_mtpdevice_struct::params.
Referenced by LIBMTP_Get_Filelisting().
π LIBMTP_file_t * LIBMTP_Get_Filemetadata (LIBMTP_mtpdevice_t * device, uint32_t const fileid)
this function retrieves the metadata for a single file off the device. one file. one struct. very lowkey π¦
π Do not call this function repeatedly! The file handles are linearly searchedO(n)and the call may involve (slow) USB traffic, so useLIBMTP_Get_Filelisting()and cache the file, preferably as an efficient data structure such as a hash list. like bestie please, i'm begging you, don't spam it π
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. so it can but it shouldn't, yk? π
Parameters
deviceβ a pointer to the device to get the file metadata from.fileidβ the object ID of the file that you want the metadata for.- Returns β a metadata entry on success, or
NULLif it failed. π - See also β
LIBMTP_Get_Filelisting() - References β
LIBMTP_mtpdevice_struct::cached, andLIBMTP_mtpdevice_struct::params. - Referenced by β
LIBMTP_Get_File_To_File_Descriptor(),LIBMTP_Get_File_To_Handler(),LIBMTP_Get_Files_And_Folders(),LIBMTP_Send_File_From_File_Descriptor(),LIBMTP_Send_File_From_Handler(), andLIBMTP_Set_Object_Filename().
πΈ LIBMTP_Get_Files_And_Folders() πΈ
LIBMTP_file_t * LIBMTP_Get_Files_And_Folders (LIBMTP_mtpdevice_t * device,
uint32_t const storage, uint32_t const parent)
Okay so this one 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, bestie β both! π«Ά
The device used with this operation must have been opened with LIBMTP_Open_Raw_Device_Uncached() or it will fail. No cap.
β οΈ NOTE: the request will always perform I/O with the device. Always. π
Parameters
- device β a pointer to the MTP device to report info from.
- storage β a storage on the device to report info from. If
0is passed in, the files for the given parent will be searched across all available storages. - parent β the parent folder id.
References β LIBMTP_mtpdevice_struct::cached, LIBMTP_Get_Filemetadata(), LIBMTP_file_struct::next, and LIBMTP_mtpdevice_struct::params.
π¦ LIBMTP_Get_Filetype_Description() π¦
char const * LIBMTP_Get_Filetype_Description (LIBMTP_filetype_t intype)
This helper function returns a textual description for a libmtp file type to be used in dialog boxes etc. It's giving very useful little string, honestly.
Parameters
- intype β the libmtp internal filetype to get a description for.
Returns β a string representing the filetype, this must NOT be free():ed by the caller!
π¨ So yeah, hands off that string, bestie. The manpage is literally yelling must NOT be free():ed by the caller! Do not free it. π
References β filemap_struct::description, and filemap_struct::id.
β¨ LIBMTP_Get_Representative_Sample() β¨
int LIBMTP_Get_Representative_Sample (LIBMTP_mtpdevice_t * device, uint32_t
const id, LIBMTP_filesampledata_t * sampledata)
This routine gets representative sample data for an object. This uses the RepresentativeSampleData property of the album, if the device supports it. Obsessed with a device that actually supports this. π₯
Parameters
- device β a pointer to the device which the object is on.
- id β unique id of the object to get data for.
- sampledata β pointer to
LIBMTP_filesampledata_tstruct to receive data.
Returns β 0 on success, any other value means failure.
See also
LIBMTP_Send_Representative_Sample()LIBMTP_Get_Representative_Sample_Format()LIBMTP_Create_New_Album()
References β LIBMTP_filesampledata_struct::data, LIBMTP_filesampledata_struct::duration, LIBMTP_filesampledata_struct::filetype, LIBMTP_filesampledata_struct::height, LIBMTP_mtpdevice_struct::params, LIBMTP_filesampledata_struct::size, and LIBMTP_filesampledata_struct::width.
π LIBMTP_Get_Representative_Sample_Format() π
int LIBMTP_Get_Representative_Sample_Format (LIBMTP_mtpdevice_t * device,
LIBMTP_filetype_t const filetype, LIBMTP_filesampledata_t ** sample)
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. the way that theoretically anything could slay this vibe check π
Parameters
- device β a pointer to the device which is to be examined.
- filetype β the filetype to examine, and return the representative sample properties for.
- sample β this will contain a new sample type with the fields filled in with suitable default values. For example, the supported sample type will be set, the supported height and width will be set to max values if it is an image sample, and duration will also be given some suitable default value which should not be exceeded on audio samples. If the device does not support samples for this filetype, this pointer will be
NULL. If it is notNULL, the user must destroy this struct withLIBMTP_destroy_filesampledata_t()after use.
Returns β 0 on success, any other value means failure.
See also
LIBMTP_Send_Representative_Sample()LIBMTP_Create_New_Album()
References β LIBMTP_filesampledata_struct::duration, LIBMTP_filesampledata_struct::filetype, LIBMTP_filesampledata_struct::height, LIBMTP_new_filesampledata_t(), LIBMTP_mtpdevice_struct::params, LIBMTP_filesampledata_struct::size, and LIBMTP_filesampledata_struct::width.
π§ LIBMTP_Get_Thumbnail() π§
int LIBMTP_Get_Thumbnail (LIBMTP_mtpdevice_t * device, uint32_t const id,
unsigned char ** data, unsigned int * size)
Retrieve the thumbnail for a file. Cute little thumbnail moment. π
Parameters
- device β a pointer to the device to get the thumbnail from.
- id β the object ID of the file to retrieve the thumbnail for.
- data β a memory pointer to retrieved thumbnail (user frees memory later when done with data).
- size β data length of retrieved thumbnail.
Returns β 0 on success, any other value means failure.
References β LIBMTP_mtpdevice_struct::params.
π LIBMTP_Handle_Events_Timeout_Completed() π
int LIBMTP_Handle_Events_Timeout_Completed (struct timeval * tv, int *
completed)
Trivial wrapper around the most generic libusb method for polling for events. Can be used to drive asynchronous event detection. Lowkey iconic little helper. β¨
π LIBMTP_new_file_t() π
LIBMTP_file_t * LIBMTP_new_file_t (void )
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 β a pointer to the newly allocated metadata structure.
See also β LIBMTP_destroy_file_t()
π LIBMTP_new_filesampledata_t() π
LIBMTP_filesampledata_t * LIBMTP_new_filesampledata_t (void )
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 β a pointer to the newly allocated metadata structure.
See also β LIBMTP_destroy_sampledata_t()
Referenced by β LIBMTP_Get_Representative_Sample_Format().
π¦ LIBMTP_Read_Event() π¦
int LIBMTP_Read_Event (LIBMTP_mtpdevice_t * device, LIBMTP_event_t * event,
uint32_t * out1)
To read events sent by the device, repeatedly call this function from a secondary thread until the return value is < 0. Periodt β loop until it says stop. π
Parameters
- device β a pointer to the MTP device to poll for events.
- event β contains a pointer to be filled in with the event retrieved if the call is successful.
- out1 β contains the
param1value from the raw event.
Returns β 0 on success, any other value means the polling loop shall be terminated immediately for this session.
References β LIBMTP_mtpdevice_struct::params.
πΈ LIBMTP_Read_Event_Async() πΈ
int LIBMTP_Read_Event_Async (LIBMTP_mtpdevice_t * device, LIBMTP_event_cb_fn
cb, void * user_data)
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. Not me calling it again and again like it's a group chat refresh π
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
- device β a pointer to the MTP device to poll for events.
- cb β a callback to be invoked when an event is received.
- user_data β arbitrary user data passed to the callback.
Returns β 0 on success, any other value means that the callback was not registered and no event notification will take place.
References β LIBMTP_mtpdevice_struct::params.
π₯ LIBMTP_Send_File_From_File() π₯
int LIBMTP_Send_File_From_File (LIBMTP_mtpdevice_t * device, char const
*const path, LIBMTP_file_t *const filedata, LIBMTP_progressfunc_t const
callback, void const *const data)
This function sends a local file to an MTP device. A filename and a set of metadata must be given as input. It's giving main character file transfer energy. π
Parameters
- device β a pointer to the device to send the track to.
- path β the filename of a local file which will be sent.
- filedata β a file metadata set to be written along with the file.
After this call the field filedata->item_id will contain the new file ID. Other fields such as the filedata->filename, filedata->parent_id or filedata->storage_id may also change during this operation due to device restrictions, so do not rely on the contents of this struct to be preserved in any way.
filedata->parent_idβ should be set to the parent (e.g. folder) to store this file in. If this is0, the file will be stored in the root folder.filedata->storage_idβ should be set to the desired storage (e.g. memory card or whatever your device presents) to store this file in. Setting this to0will store the file on the primary storage.
- callback β a progress indicator function or
NULLto 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 β 0 if the transfer was successful, any other value means failure.
See also
LIBMTP_Send_File_From_File_Descriptor()LIBMTP_Delete_Object()
References β LIBMTP_Send_File_From_File_Descriptor().
π« LIBMTP_Send_File_From_File_Descriptor() π«
int LIBMTP_Send_File_From_File_Descriptor (LIBMTP_mtpdevice_t * device, int
const fd, LIBMTP_file_t *const filedata, LIBMTP_progressfunc_t const
callback, void const *const data)
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
so for this sender function, the params are:
deviceβ a pointer to the device to send the file to. π«Άfdβ the filedescriptor for a local file which will be sent.filedataβ a file metadata set to be written along with the file. After this call the fieldfiledata->item_idwill contain the new file ID. Other fields such asfiledata->filename,filedata->parent_idorfiledata->storage_idmay also change during this operation due to device restrictions, so do not rely on the contents of this struct to be preserved in any way. πfiledata->parent_idshould be set to the parent (e.g. folder) to store this file in. If this is0, the file will be stored in the root folder.filedata->storage_idshould be set to the desired storage (e.g. memory card or whatever your device presents) to store this file in. Setting this to0will store the file on the primary storage.
callbackβ a progress indicator function orNULLto 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 toNULL.
Returns
0 if the transfer was successful, any other value means failure. π
See also
LIBMTP_Send_File_From_File()LIBMTP_Send_Track_From_File_Descriptor()LIBMTP_Delete_Object()
References
_PTP_USB::callback_active, LIBMTP_file_struct::filesize, LIBMTP_file_struct::item_id, LIBMTP_destroy_file_t(), LIBMTP_Get_Filemetadata(), LIBMTP_mtpdevice_struct::params, LIBMTP_file_struct::parent_id, LIBMTP_file_struct::storage_id, and LIBMTP_mtpdevice_struct::usbinfo.
Referenced by
LIBMTP_Send_File_From_File(), and LIBMTP_Send_Track_From_File_Descriptor().
LIBMTP_Send_File_From_Handler()
int LIBMTP_Send_File_From_Handler (LIBMTP_mtpdevice_t * device,
MTPDataGetFunc get_func, void * priv, LIBMTP_file_t *const filedata,
LIBMTP_progressfunc_t const callback, void const *const data)
Okay so this one 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
deviceβ a pointer to the device to send the file to.get_funcβ the function to call to get data to writeprivβ a user-defined pointer that is passed along toget_func. If not used, this is set toNULL.filedataβ a file metadata set to be written along with the file. After this call the fieldfiledata->item_idwill contain the new file ID. Other fields such asfiledata->filename,filedata->parent_idorfiledata->storage_idmay also change during this operation due to device restrictions, so do not rely on the contents of this struct to be preserved in any way. πfiledata->parent_idshould be set to the parent (e.g. folder) to store this file in. If this is0, the file will be stored in the root folder.filedata->storage_idshould be set to the desired storage (e.g. memory card or whatever your device presents) to store this file in. Setting this to0will store the file on the primary storage.
callbackβ a progress indicator function orNULLto 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 toNULL.
Returns
0 if the transfer was successful, any other value means failure.
See also
LIBMTP_Send_File_From_File()LIBMTP_Send_Track_From_File_Descriptor()LIBMTP_Delete_Object()
References
_PTP_USB::callback_active, LIBMTP_file_struct::filesize, LIBMTP_file_struct::item_id, LIBMTP_destroy_file_t(), LIBMTP_Get_Filemetadata(), LIBMTP_mtpdevice_struct::params, LIBMTP_file_struct::parent_id, LIBMTP_file_struct::storage_id, and LIBMTP_mtpdevice_struct::usbinfo.
Referenced by
LIBMTP_Send_Track_From_Handler().
LIBMTP_Send_Representative_Sample()
int LIBMTP_Send_Representative_Sample (LIBMTP_mtpdevice_t * device, uint32_t
const id, LIBMTP_filesampledata_t * sampledata)
This routine sends representative sample data for an object. It 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
deviceβ a pointer to the device which the object is on.idβ unique id of the object to set artwork for.sampledataβ pointer toLIBMTP_filesampledata_tstruct containing data
Returns
0 on success, any other value means failure.
See also
LIBMTP_Get_Representative_Sample()LIBMTP_Get_Representative_Sample_Format()LIBMTP_Create_New_Album()
References
LIBMTP_filesampledata_struct::data, LIBMTP_filesampledata_struct::duration, LIBMTP_filesampledata_struct::filetype, LIBMTP_filesampledata_struct::height, LIBMTP_mtpdevice_struct::params, LIBMTP_filesampledata_struct::size, LIBMTP_mtpdevice_struct::usbinfo, and LIBMTP_filesampledata_struct::width.
LIBMTP_Set_File_Name()
int LIBMTP_Set_File_Name (LIBMTP_mtpdevice_t * device, LIBMTP_file_t * file,
const char * newname)
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
deviceβ a pointer to the device that contains the file.fileβ the file metadata of the file to rename. On success, thefilenamemember is updated. Be aware, that this name can be different thannewnamedepending of device restrictions.newnameβ the new filename for this object.
Returns
0 on success, any other value means failure.
References
LIBMTP_file_struct::filename, LIBMTP_file_struct::filetype, and LIBMTP_file_struct::item_id.
β¨ Author β¨
Generated automatically by Doxygen for libmtp from the source code. π€π
and that's the whole page, bestie β source/version tea is libmtp Version 1.1.23 on files(3), and the footer doesn't show a date, so no fake date energy here ππ
π¦ where this page comes from
- arch rolling: libmtp 1.1.23-1 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms