B2G/gecko/toolkit/mozapps/update/test/shared.js
/**
 * Deletes a directory and its children. First it tries nsIFile::Remove(true).
 * If that fails it will fall back to recursing, setting the appropriate
 * permissions, and deleting the current entry.
 *
 * @param  aDir
 *         nsIFile for the directory to be deleted.
 */
Deletes a directory and its children.

@param  aDir
nsIFile for the directory to be deleted.
Deletes a directory and its children . @param aDir nsIFile for the directory to be deleted .
function removeDirRecursive(aDir) {
  if (!aDir.exists())
    return;
  try {
    aDir.remove(true);
    return;
  }
  catch (e) {
  }
  var dirEntries = aDir.directoryEntries;
  while (dirEntries.hasMoreElements()) {
    var entry = dirEntries.getNext().QueryInterface(AUS_Ci.nsIFile);
    if (entry.isDirectory()) {
      removeDirRecursive(entry);
    }
    else {
      entry.permissions = PERMS_FILE;
      entry.remove(false);
    }
  }
  aDir.permissions = PERMS_DIRECTORY;
  aDir.remove(true);
}
function removeDirRecursive ( aDir ) { if ( ! aDir . exists ( ) ) return ; try { aDir . remove ( true ) ; return ; } catch ( e ) { } var dirEntries = aDir . directoryEntries ; while ( dirEntries . hasMoreElements ( ) ) { var entry = dirEntries . getNext ( ) . QueryInterface ( AUS_Ci . nsIFile ) ; if ( entry . isDirectory ( ) ) { removeDirRecursive ( entry ) ; } else { entry . permissions = PERMS_FILE ; entry . remove ( false ) ; } } aDir . permissions = PERMS_DIRECTORY ; aDir . remove ( true ) ; }
Deletes a directory and its children.
Deletes a directory and its children .