From bcf051717a9fab03e032959ac2d3904c45e59ee5 Mon Sep 17 00:00:00 2001 From: David Daynard Date: Tue, 12 Mar 2013 18:35:09 -0400 Subject: MediaScanner: Ignore dirs with .noscanandnomtp Completely ignore directories with .noscanandnomtp files in them. Placing a .nomedia file will still scan a directory but exclude it from the media database. This is so the file may still be presented for MTP purposes. Placing .noscanandnomtp completely prevents the scan, which saves considerable processing power and battery life on systems with numerous media files, but prevents them from being seen over MTP. Change-Id: Ibff2a9f2525255a2ac34132eeee36734962fbdd7 --- media/libmedia/MediaScanner.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/media/libmedia/MediaScanner.cpp b/media/libmedia/MediaScanner.cpp index 28b5aa7..6ea5b7e 100644 --- a/media/libmedia/MediaScanner.cpp +++ b/media/libmedia/MediaScanner.cpp @@ -139,6 +139,18 @@ MediaScanResult MediaScanner::doProcessDirectory( return MEDIA_SCAN_RESULT_OK; } + // Completely skip all directories containing a ".noscanandnomtp" file + if (pathRemaining >= 15 /* strlen(".noscanandnomtp") */ ) { + strcpy(fileSpot, ".noscanandnomtp"); + if (access(path, F_OK) == 0) { + ALOGV("found .noscanandnomtp, completely skipping"); + return MEDIA_SCAN_RESULT_SKIPPED; + } + + // restore path + fileSpot[0] = 0; + } + // Treat all files as non-media in directories that contain a ".nomedia" file if (pathRemaining >= 8 /* strlen(".nomedia") */ ) { strcpy(fileSpot, ".nomedia"); -- cgit v1.1