MTP: Better handling of stat

Do some error checking of lstat calls and better handle those
errors.
Use lstat instead of dirent to check if an item is a directory
because dirent does not return the correct item type when using
exfat-fuse.

Change-Id: I0d008aff55a0e0b4fbeae24cf8d0c04453b7b77e
This commit is contained in:
Ethan Yonker
2014-09-04 13:05:35 -05:00
parent 2e07c0493e
commit 241a3ce4c5
3 changed files with 47 additions and 26 deletions
+6 -1
View File
@@ -1132,7 +1132,12 @@ static void deleteRecursive(const char* path) {
strcpy(fileSpot, name);
int type = entry->d_type;
if (entry->d_type == DT_DIR) {
struct stat st;
if (lstat(pathbuf, &st)) {
MTPE("Failed to lstat '%s'\n", pathbuf);
continue;
}
if (st.st_mode & S_IFDIR) {
deleteRecursive(pathbuf);
rmdir(pathbuf);
} else {