summaryrefslogtreecommitdiffstats
path: root/media/libmedia/MediaScanner.cpp
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2010-06-14 22:57:22 -0700
committerMike Lockwood <lockwood@android.com>2010-06-14 22:57:22 -0700
commitef04e8f230e7ef5dece1cc4e73cd109c69905418 (patch)
treebf01ceb455b1d0c426de2a11189c5eb4724cec67 /media/libmedia/MediaScanner.cpp
parentc42aa12f73edf79bc9cb0dbf6b74a7f1af11c683 (diff)
downloadframeworks_av-ef04e8f230e7ef5dece1cc4e73cd109c69905418.zip
frameworks_av-ef04e8f230e7ef5dece1cc4e73cd109c69905418.tar.gz
frameworks_av-ef04e8f230e7ef5dece1cc4e73cd109c69905418.tar.bz2
MediaScanner: Fix handling of files with dirent.d_type == DT_UNKNOWN
The previous code was calling stat() on the parent directory rather than the actual file. Change-Id: If64552cb37552c77618a81ae4333307a018efe13 Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'media/libmedia/MediaScanner.cpp')
-rw-r--r--media/libmedia/MediaScanner.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/media/libmedia/MediaScanner.cpp b/media/libmedia/MediaScanner.cpp
index 843a8fd..b2a6109 100644
--- a/media/libmedia/MediaScanner.cpp
+++ b/media/libmedia/MediaScanner.cpp
@@ -129,6 +129,13 @@ status_t MediaScanner::doProcessDirectory(
continue;
}
+ int nameLength = strlen(name);
+ 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.
@@ -146,16 +153,7 @@ status_t MediaScanner::doProcessDirectory(
}
}
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;