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:
+6
-1
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user