Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: patches/19_raw_read_directory.patch

Issue 365823004: Add LIBMTP_Get_Children() to read the list of raw IDs of a folder. (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libmtp.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/libmtp.h » ('j') | src/libmtp.c » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 diff --git src/libmtp.c src/libmtp.c
2 index b91f246..a0a0c7b 100644
3 --- src/libmtp.c
4 +++ src/libmtp.c
5 @@ -4415,6 +4415,75 @@ LIBMTP_file_t * LIBMTP_Get_Files_And_Folders(LIBMTP_mtpde vice_t *device,
6 return retfiles;
7 }
8
9 +/**
10 + * This function retrieves the list of ids of files and folders in a certain
11 + * folder with id parent on a certain storage on a certain device.
12 + * The device used with this operations must have been opened with
13 + * LIBMTP_Open_Raw_Device_Uncached() or it will fail.
14 + *
15 + * NOTE: the request will always perform I/O with the device.
16 + * @param device a pointer to the MTP device to report info from.
17 + * @param storage a storage on the device to report info from. If
18 + * 0 is passed in, the files for the given parent will be
19 + * searched across all available storages.
20 + * @param parent the parent folder id.
21 + * @param out the pointer where the array of ids is returned.
22 + */
23 +
24 +int LIBMTP_Get_Children(LIBMTP_mtpdevice_t *device,
25 + uint32_t const storage,
26 + uint32_t const parent,
27 + uint32_t** out)
28 +{
29 + PTPParams *params = (PTPParams *) device->params;
30 + PTP_USB *ptp_usb = (PTP_USB*) device->usbinfo;
31 + LIBMTP_file_t *retfiles = NULL;
32 + LIBMTP_file_t *curfile = NULL;
33 + PTPObjectHandles currentHandles;
34 + uint32_t storageid;
35 + uint16_t ret;
36 + int i = 0;
37 +
38 + if (device->cached) {
39 + // This function is only supposed to be used by devices
40 + // opened as uncached!
41 + LIBMTP_ERROR("tried to use %s on a cached device!\n", __func__);
42 + return -1;
43 + }
44 +
45 + if (FLAG_BROKEN_GET_OBJECT_PROPVAL(ptp_usb)) {
46 + // These devices cannot handle the commands needed for
47 + // Uncached access!
48 + LIBMTP_ERROR("tried to use %s on an unsupported device, "
49 + "this command does not work on all devices "
50 + "due to missing low-level support to read "
51 + "information on individual tracks\n",
52 + __func__);
53 + return -1;
54 + }
55 +
56 + if (storage == 0)
57 + storageid = PTP_GOH_ALL_STORAGE;
58 + else
59 + storageid = storage;
60 +
61 + ret = ptp_getobjecthandles(params,
62 + storageid,
63 + PTP_GOH_ALL_FORMATS,
64 + parent,
65 + &currentHandles);
66 +
67 + if (ret != PTP_RC_OK) {
68 + add_ptp_error_to_errorstack(device, ret,
69 + "LIBMTP_Get_Children(): could not get object handles.");
70 + return -1;
71 + }
72 +
73 + if (currentHandles.Handler == NULL || currentHandles.n == 0)
74 + return 0;
75 + *out = currentHandles.Handler;
76 + return currentHandles.n;
77 +}
78
79 /**
80 * This creates a new track metadata structure and allocates memory
81 diff --git src/libmtp.h src/libmtp.h
82 index 33fac41..8177b74 100644
83 --- src/libmtp.h
84 +++ src/libmtp.h
85 @@ -875,6 +875,10 @@ LIBMTP_file_t *LIBMTP_Get_Filelisting_With_Callback(LIBMTP_ mtpdevice_t *,
86 LIBMTP_file_t * LIBMTP_Get_Files_And_Folders(LIBMTP_mtpdevice_t *,
87 uint32_t const,
88 uint32_t const);
89 +int LIBMTP_Get_Children(LIBMTP_mtpdevice_t *,
90 + uint32_t const,
91 + uint32_t const,
92 + uint32_t**);
93 LIBMTP_file_t *LIBMTP_Get_Filemetadata(LIBMTP_mtpdevice_t *, uint32_t const);
94 int LIBMTP_Get_File_Chunk(LIBMTP_mtpdevice_t*, uint32_t, uint32_t, uint32_t,
95 unsigned char**, uint32_t*);
96 diff --git src/libmtp.h.in src/libmtp.h.in
97 index b49d449..2b2f0bb 100644
98 --- src/libmtp.h.in
99 +++ src/libmtp.h.in
100 @@ -875,6 +875,10 @@ LIBMTP_file_t *LIBMTP_Get_Filelisting_With_Callback(LIBMTP_ mtpdevice_t *,
101 LIBMTP_file_t * LIBMTP_Get_Files_And_Folders(LIBMTP_mtpdevice_t *,
102 uint32_t const,
103 uint32_t const);
104 +int LIBMTP_Get_Children(LIBMTP_mtpdevice_t *,
105 + uint32_t const,
106 + uint32_t const,
107 + uint32_t**);
108 LIBMTP_file_t *LIBMTP_Get_Filemetadata(LIBMTP_mtpdevice_t *, uint32_t const);
109 int LIBMTP_Get_File_Chunk(LIBMTP_mtpdevice_t*, uint32_t, uint32_t, uint32_t,
110 unsigned char**, uint32_t*);
111 diff --git src/libmtp.sym src/libmtp.sym
112 index b6951b2..4130fe8 100644
113 --- src/libmtp.sym
114 +++ src/libmtp.sym
115 @@ -48,6 +48,7 @@ LIBMTP_Get_Filetype_Description
116 LIBMTP_Get_Filelisting
117 LIBMTP_Get_Filelisting_With_Callback
118 LIBMTP_Get_Files_And_Folders
119 +LIBMTP_Get_Children
120 LIBMTP_Get_Filemetadata
121 LIBMTP_Get_File_Chunk
122 LIBMTP_Get_File_To_File
OLDNEW
« no previous file with comments | « no previous file | src/libmtp.h » ('j') | src/libmtp.c » ('J')

Powered by Google App Engine
This is Rietveld 408576698