|
From: libmtp <li...@mn...> - 2008-02-17 21:25:05
|
On my "Samsung YP-U3JQW", "mtp-delfile" didn't work for
either "mtp-delfile -n fileid" or "mtp-delfile -f filename"
using "libmtp-0.2.5".
I'm not up on these things and perhaps this has already been
discussed or even fixed, but in case not fyi:
(1) mtp-delfile -n fileid
The Samsung YP-U3JQW apparently uses the full 32 bits for
a "fileid" and in "libmtp-0.2.5/examples/delfile.c", in
both functions delfile_function() and delfile_command()
there is,
int id;
In both places I changed it to:
unsigned id;
And I could then delete files by "fileid".
(2) mtp-delfile -f filename
Although the usage message for "mtp-delfile" says this should
work, there is no code to convert the "filename" to a "fileid"
and "mtp-delfile" was failing silently. I fixed this in the
function parse_path() in file "libmtp-0.2.5/examples/pathutils.c",
by adding some code to:
if (*path != '/') {
int item_id = strtoul(path, &rest, 0);
// really should check contents of "rest" here...
return item_id;
}
Resulting in:
if (*path != '/') {
int item_id = strtoul(path, &rest, 0);
// really should check contents of "rest" here...
if (item_id == 0) { /* if not number, assume a file name */
LIBMTP_file_t * file = files;
while (file != NULL) { /* search for matching name */
if (strcasecmp (file->filename, path) == 0) {
return file->item_id; /* found it */
}
file = file->next;
}
}
return item_id;
}
I'm new to "libmtp" so no guarantees that I haven't broken something.
But I just wanted to give something back to this project, since as a
linux only user "libmtp" made it possible for me to use my "YP-U3"
which I bought not realizing it wouldn't mount as a file system.
|