Loading media/libmedia/MediaScanner.cpp +26 −28 Original line number Diff line number Diff line Loading @@ -127,12 +127,21 @@ status_t MediaScanner::doProcessDirectory( while ((entry = readdir(dir))) { const char* name = entry->d_name; int nameLength = strlen(name); // ignore "." and ".." if (name[0] == '.' && (name[1] == 0 || (name[1] == '.' && name[2] == 0))) { continue; } /* also keep space for '/' in case it's a directory */ if (nameLength + 1 > pathRemaining) { // path too long! continue; } strcpy(fileSpot, name); int type = entry->d_type; if (type == DT_UNKNOWN) { // If the type is unknown, stat() the file instead. Loading @@ -149,17 +158,7 @@ status_t MediaScanner::doProcessDirectory( LOGD("stat() failed for %s: %s", path, strerror(errno) ); } } if (type == DT_REG || type == DT_DIR) { int nameLength = strlen(name); bool isDirectory = (type == DT_DIR); if (nameLength > pathRemaining || (isDirectory && nameLength + 1 > pathRemaining)) { // path too long! continue; } strcpy(fileSpot, name); if (isDirectory) { if (type == DT_DIR) { // ignore directories with a name that starts with '.' // for example, the Mac ".Trashes" directory if (name[0] == '.') continue; Loading @@ -172,7 +171,7 @@ status_t MediaScanner::doProcessDirectory( LOGE("Error processing '%s' - skipping\n", path); continue; } } else if (fileMatchesExtension(path, extensions)) { } else if (type == DT_REG && fileMatchesExtension(path, extensions)) { struct stat statbuf; stat(path, &statbuf); if (statbuf.st_size > 0) { Loading @@ -181,7 +180,6 @@ status_t MediaScanner::doProcessDirectory( if (exceptionCheck && exceptionCheck(exceptionEnv)) goto failure; } } } closedir(dir); return OK; Loading Loading
media/libmedia/MediaScanner.cpp +26 −28 Original line number Diff line number Diff line Loading @@ -127,12 +127,21 @@ status_t MediaScanner::doProcessDirectory( while ((entry = readdir(dir))) { const char* name = entry->d_name; int nameLength = strlen(name); // ignore "." and ".." if (name[0] == '.' && (name[1] == 0 || (name[1] == '.' && name[2] == 0))) { continue; } /* also keep space for '/' in case it's a directory */ if (nameLength + 1 > pathRemaining) { // path too long! continue; } strcpy(fileSpot, name); int type = entry->d_type; if (type == DT_UNKNOWN) { // If the type is unknown, stat() the file instead. Loading @@ -149,17 +158,7 @@ status_t MediaScanner::doProcessDirectory( LOGD("stat() failed for %s: %s", path, strerror(errno) ); } } if (type == DT_REG || type == DT_DIR) { int nameLength = strlen(name); bool isDirectory = (type == DT_DIR); if (nameLength > pathRemaining || (isDirectory && nameLength + 1 > pathRemaining)) { // path too long! continue; } strcpy(fileSpot, name); if (isDirectory) { if (type == DT_DIR) { // ignore directories with a name that starts with '.' // for example, the Mac ".Trashes" directory if (name[0] == '.') continue; Loading @@ -172,7 +171,7 @@ status_t MediaScanner::doProcessDirectory( LOGE("Error processing '%s' - skipping\n", path); continue; } } else if (fileMatchesExtension(path, extensions)) { } else if (type == DT_REG && fileMatchesExtension(path, extensions)) { struct stat statbuf; stat(path, &statbuf); if (statbuf.st_size > 0) { Loading @@ -181,7 +180,6 @@ status_t MediaScanner::doProcessDirectory( if (exceptionCheck && exceptionCheck(exceptionEnv)) goto failure; } } } closedir(dir); return OK; Loading