summaryrefslogtreecommitdiffstats
path: root/media/libmedia
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2010-09-10 14:47:36 -0400
committerMike Lockwood <lockwood@android.com>2010-09-12 23:21:44 -0400
commitc37255d5d0fd9e0ec02b0d7cb5c4b235e200d367 (patch)
tree6feb14e577a8ed66bf2c2afe6b39f47246b9cf49 /media/libmedia
parent6d000d4eb733fc6ad7fcd27a4022a41f8433306d (diff)
downloadframeworks_base-c37255d5d0fd9e0ec02b0d7cb5c4b235e200d367.zip
frameworks_base-c37255d5d0fd9e0ec02b0d7cb5c4b235e200d367.tar.gz
frameworks_base-c37255d5d0fd9e0ec02b0d7cb5c4b235e200d367.tar.bz2
Media scanner support for tracking files of arbitrary type.
The native media scanner no longer filters files based on file extension. Audio, video, image and playlist files are handled as before, but non-media files are now inserted into the "files" table, which was originally added to support MTP. Change-Id: I9053218fb6d2671a3bb181405c34442b94678afc Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'media/libmedia')
-rw-r--r--media/libmedia/MediaScanner.cpp32
1 files changed, 6 insertions, 26 deletions
diff --git a/media/libmedia/MediaScanner.cpp b/media/libmedia/MediaScanner.cpp
index ba98f04..c31b622 100644
--- a/media/libmedia/MediaScanner.cpp
+++ b/media/libmedia/MediaScanner.cpp
@@ -48,8 +48,7 @@ const char *MediaScanner::locale() const {
}
status_t MediaScanner::processDirectory(
- const char *path, const char *extensions,
- MediaScannerClient &client,
+ const char *path, MediaScannerClient &client,
ExceptionCheck exceptionCheck, void *exceptionEnv) {
int pathLength = strlen(path);
if (pathLength >= PATH_MAX) {
@@ -72,35 +71,16 @@ status_t MediaScanner::processDirectory(
status_t result =
doProcessDirectory(
- pathBuffer, pathRemaining, extensions, client,
- exceptionCheck, exceptionEnv);
+ pathBuffer, pathRemaining, client, exceptionCheck, exceptionEnv);
free(pathBuffer);
return result;
}
-static bool fileMatchesExtension(const char* path, const char* extensions) {
- const char* extension = strrchr(path, '.');
- if (!extension) return false;
- ++extension; // skip the dot
- if (extension[0] == 0) return false;
-
- while (extensions[0]) {
- const char* comma = strchr(extensions, ',');
- size_t length = (comma ? comma - extensions : strlen(extensions));
- if (length == strlen(extension) && strncasecmp(extension, extensions, length) == 0) return true;
- extensions += length;
- if (extensions[0] == ',') ++extensions;
- }
-
- return false;
-}
-
status_t MediaScanner::doProcessDirectory(
- char *path, int pathRemaining, const char *extensions,
- MediaScannerClient &client, ExceptionCheck exceptionCheck,
- void *exceptionEnv) {
+ char *path, int pathRemaining, MediaScannerClient &client,
+ ExceptionCheck exceptionCheck, void *exceptionEnv) {
// place to copy file or directory name
char* fileSpot = path + strlen(path);
struct dirent* entry;
@@ -163,14 +143,14 @@ status_t MediaScanner::doProcessDirectory(
if (name[0] == '.') continue;
strcat(fileSpot, "/");
- int err = doProcessDirectory(path, pathRemaining - nameLength - 1, extensions, client, exceptionCheck, exceptionEnv);
+ int err = doProcessDirectory(path, pathRemaining - nameLength - 1, client, exceptionCheck, exceptionEnv);
if (err) {
// pass exceptions up - ignore other errors
if (exceptionCheck && exceptionCheck(exceptionEnv)) goto failure;
LOGE("Error processing '%s' - skipping\n", path);
continue;
}
- } else if (fileMatchesExtension(path, extensions)) {
+ } else {
struct stat statbuf;
stat(path, &statbuf);
if (statbuf.st_size > 0) {