// Path: src/com/zlab/datFM/swiftp/MediaUpdater.java
// public enum MediaUpdater {
//     INSTANCE;
//     
//     private final static String TAG = MediaUpdater.class.getSimpleName();
// 
//     // the systembroadcast to remount the media is only done after a little while (5s)
//     private static Timer sTimer = new Timer();
// 
//     public static void notifyFileCreated(String path) {
//         if (Defaults.do_mediascanner_notify) {
//             Log.d(TAG, "Notifying others about new file: " + path);
//             Context context = FtpServerApp.getAppContext();
//             MediaScannerConnection.scanFile(context, new String[]{path}, null,
//                     new MediaScannerConnection.OnScanCompletedListener() {
//                         @Override
//                         public void onScanCompleted(String path, Uri uri) {
//                         }
//                     });
//         }
//     }
// 
//     public static void notifyFileDeleted(String path) {
//         // The media mounted broadcast is very taxing on the system, so we only do this
//         // if for 5 seconds there was no same request, otherwise we wait again.
//         if (Defaults.do_mediascanner_notify) {
//             Log.d(TAG, "Notifying others about deleted file: " + path);
//             // the systembroadcast might have been requested already, cancel if so
//             sTimer.cancel();
//             // that timer is of no value any more, create a new one
//             sTimer = new Timer();
//             // and in 5s let it send the broadcast, might never hapen if before
//             // that time it gets canceled by this code path
//             sTimer.schedule(new TimerTask() {
//                 @Override
//                 public void run() {
//                     Log.d(TAG, "Sending ACTION_MEDIA_MOUNTED broadcast");
//                     final Context context = FtpServerApp.getAppContext();
//                     context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri
//                             .parse("file://" + Environment.getExternalStorageDirectory())));
//                 }
//             }, 5000);
//         }
//     }
// 
// }


import com.zlab.datFM.swiftp.MediaUpdater;
import java.io.File;
import android.util.Log;
            sessionThread.writeString(errString);
            Log.i(TAG, "RMD failed: " + errString.trim());
        } else {
            sessionThread.writeString("250 Removed directory\r\n");
        }
        Log.d(TAG, "RMD finished");
    }

    /**
     * Accepts a file or directory name, and recursively deletes the contents of that
     * directory and all subdirectories.
     * 
     * @param toDelete
     * @return Whether the operation completed successfully
     */
    protected boolean recursiveDelete(File toDelete) {
        if (!toDelete.exists()) {
            return false;
        }
        if (toDelete.isDirectory()) {
            // If any of the recursive operations fail, then we return false
            boolean success = true;
            for (File entry : toDelete.listFiles()) {
                success &= recursiveDelete(entry);
            }
            Log.d(TAG, "Recursively deleted: " + toDelete);
            return success && toDelete.delete();
        } else {
            Log.d(TAG, "RMD deleting file: " + toDelete);
            boolean success = toDelete.delete();
// Path: src/com/zlab/datFM/swiftp/MediaUpdater.java
// public enum MediaUpdater {
//     INSTANCE;
//     
//     private final static String TAG = MediaUpdater.class.getSimpleName();
// 
//     // the systembroadcast to remount the media is only done after a little while (5s)
//     private static Timer sTimer = new Timer();
// 
//     public static void notifyFileCreated(String path) {
//         if (Defaults.do_mediascanner_notify) {
//             Log.d(TAG, "Notifying others about new file: " + path);
//             Context context = FtpServerApp.getAppContext();
//             MediaScannerConnection.scanFile(context, new String[]{path}, null,
//                     new MediaScannerConnection.OnScanCompletedListener() {
//                         @Override
//                         public void onScanCompleted(String path, Uri uri) {
//                         }
//                     });
//         }
//     }
// 
//     public static void notifyFileDeleted(String path) {
//         // The media mounted broadcast is very taxing on the system, so we only do this
//         // if for 5 seconds there was no same request, otherwise we wait again.
//         if (Defaults.do_mediascanner_notify) {
//             Log.d(TAG, "Notifying others about deleted file: " + path);
//             // the systembroadcast might have been requested already, cancel if so
//             sTimer.cancel();
//             // that timer is of no value any more, create a new one
//             sTimer = new Timer();
//             // and in 5s let it send the broadcast, might never hapen if before
//             // that time it gets canceled by this code path
//             sTimer.schedule(new TimerTask() {
//                 @Override
//                 public void run() {
//                     Log.d(TAG, "Sending ACTION_MEDIA_MOUNTED broadcast");
//                     final Context context = FtpServerApp.getAppContext();
//                     context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri
//                             .parse("file://" + Environment.getExternalStorageDirectory())));
//                 }
//             }, 5000);
//         }
//     }
// 
// }


// Path: src/com/zlab/datFM/swiftp/server/CmdRMD.java
import com.zlab.datFM.swiftp.MediaUpdater;
import java.io.File;
import android.util.Log;

            sessionThread.writeString(errString);
            Log.i(TAG, "RMD failed: " + errString.trim());
        } else {
            sessionThread.writeString("250 Removed directory\r\n");
        }
        Log.d(TAG, "RMD finished");
    }

    /**
     * Accepts a file or directory name, and recursively deletes the contents of that
     * directory and all subdirectories.
     * 
     * @param toDelete
     * @return Whether the operation completed successfully
     */
    protected boolean recursiveDelete(File toDelete) {
        if (!toDelete.exists()) {
            return false;
        }
        if (toDelete.isDirectory()) {
            // If any of the recursive operations fail, then we return false
            boolean success = true;
            for (File entry : toDelete.listFiles()) {
                success &= recursiveDelete(entry);
            }
            Log.d(TAG, "Recursively deleted: " + toDelete);
            return success && toDelete.delete();
        } else {
            Log.d(TAG, "RMD deleting file: " + toDelete);
            boolean success = toDelete.delete();
            MediaUpdater.notifyFileDeleted(toDelete.getPath());