Delete the given file in a separate thread

@param file The file to delete
548677
private void deleteAsync(final File file) {
        new Thread(new Runnable() {

            @Override
            public void run() {
                try {
                    try {
                        logger.info("Waiting for " + deleteBackupMs
                                    + " milliseconds before deleting " + file.getAbsolutePath());
                        Thread.sleep(deleteBackupMs);
                    } catch(InterruptedException e) {
                        logger.warn("Did not sleep enough before deleting backups");
                    }
                    logger.info("Deleting file " + file.getAbsolutePath());
                    Utils.rm(file);
                    logger.info("Deleting of " + file.getAbsolutePath()
                                + " completed successfully.");
                    storeVersionManager.syncInternalStateFromFileSystem(true);
                } catch(Exception e) {
                    logger.error("Exception during deleteAsync for path: " + file, e);
                }
            }
        }, "background-file-delete").start();
    }
523966
public void file(File file) {
        try {
            contentLength(file.length());
            file(file.getName(), new FileInputStream(file));
        } catch (FileNotFoundException e) {
            throw new PippoRuntimeException(e);
        }
    }
1067330
public void setPersistedFile(File file) throws FileNotFoundException
   {
      if (file instanceof SwapFile)
      {
         ((SwapFile)file).acquire(this);
      }

      this.file = file;

      // JCR-2326 Release the current ValueData from tempFile users before
      // setting its reference to null so it will be garbage collected.
      if (this.tempFile != null)
      {
         this.tempFile.release(this);
         this.tempFile = null;
      }

      this.stream = null;
   }
703599
public static void delete(File file) throws IOException{
        if(!file.exists())
            return;

        if(file.isFile()){
            if(!file.delete())
                throw new IOException("couldn't delete file :"+file);
        }else{
            try{
                WalkerUtil.walk(new PreorderWalker<File>(file, FileNavigator.INSTANCE), new Processor<File>(){
                    @Override
                    public boolean preProcess(File file, Path path){
                        return true;
                    }

                    @Override
                    public void postProcess(File file, Path path){
                        try{
                            if(!file.delete())
                                throw new IOException("couldn't delete file :"+file);
                        }catch(IOException ex){
                            throw new RuntimeException(ex);
                        }
                    }
                });
            }catch(RuntimeException ex){
                if(ex.getCause() instanceof IOException)
                    throw (IOException)ex.getCause();
                else
                    throw ex;
            }
        }
    }
384208
private static void delete(File file) {
    if (file.isDirectory()) {
      File[] files = file.listFiles();
      if (files != null) {
        for (File child : files) {
          delete(child);
        }
      }
    }

    file.delete();
  }
1005309
public void onFileChange(File file) {
        LOG.info("File updated : {}", file.getAbsolutePath());
        onFileDelete(file);
        onFileCreate(file);
    }
677793
public static boolean destroy(File file) {
        if (!file.exists()) return false;

        RandomAccessFile f = null;
        long size = file.length();
        try {
            f = new RandomAccessFile(file, "rw");
            long rec = size/DMSG.length();
            int left = (int)(size - rec*DMSG.length());
            while(rec != 0) {
                f.write(DMSG.getBytes(), 0, DMSG.length());
                rec--;
            }
            if (left > 0) {
                f.write(DMSG.getBytes(), 0, left);
            }
        } catch(Exception e) {
            return false;
        } finally {
            try {
                if (f != null) f.close();
            } catch(Exception e) {}
        }

        return file.delete();
    }
1240075
public function deleteFile($file)
    {
        if (!$this->filesystem->has($file)) {
            return;
        }

        $this->filesystem->delete($file);
        $this->cacheManager->remove($file);
    }
427534
private static void deleteOldFile(final File file) {
		if (!file.exists()) {
			return;
		}

		LOG.debug("删除旧文件：{}", file);
		boolean success = file.delete();
		if (!success) {
			LOG.warn("删除文件失败：{}", file);
		}
	}
775819
public static void deleteFilesRecursivelyAndQuietly( File... files ) {

		try {
			deleteFilesRecursively( files );

		} catch( IOException e ) {
			Logger logger = Logger.getLogger( Utils.class.getName());
			logException( logger, e );
		}
	}
1267244
private void resetFile(String file) {
    File f = new File(file);
    if (f.exists()) {
      JMetalLogger.logger.info("Already existing file " + file);

      if (f.isDirectory()) {
        JMetalLogger.logger.info("Deleting directory " + file);
        if (f.delete()) {
          JMetalLogger.logger.info("Directory successfully deleted.");
        } else {
          JMetalLogger.logger.info("Error deleting directory.");
        }
      } else {
        JMetalLogger.logger.info("Deleting file " + file);
        if (f.delete()) {
          JMetalLogger.logger.info("File successfully deleted.");
        } else {
          JMetalLogger.logger.info("Error deleting file.");
        }
      }
    } else {
      JMetalLogger.logger.info("File " + file + " does NOT exist.");
    }
  }
1256846
void deleteAsyncFile(FSDataset.FSVolume volume, File file){
	    DataNode.LOG.info("Scheduling file " + file.toString() + " for deletion");
	    FileDeleteTask deletionTask =
	        new FileDeleteTask(volume, file);
	    execute(volume.getCurrentDir(), deletionTask);
	  }
425408
public void release() {
        if (lock != null) {
            try {
                lock.release();
                lock = null;
            } catch (IOException ex) {
                LOGGER.debug("Failed to release lock", ex);
            }
        }
        if (file != null) {
            try {
                file.close();
                file = null;
            } catch (IOException ex) {
                LOGGER.debug("Unable to delete lock file", ex);
            }
        }
        if (lockFile != null && lockFile.isFile()) {
            final String msg = readLockFile();
            if (msg != null && msg.equals(magic) && !lockFile.delete()) {
                LOGGER.error("Lock file '{}' was unable to be deleted. Please manually delete this file.", lockFile.toString());
                lockFile.deleteOnExit();
            }
        }
        lockFile = null;
        removeShutdownHook();
        final Timestamp timestamp = new Timestamp(System.currentTimeMillis());
        LOGGER.debug("Lock released ({}) {} @ {}", Thread.currentThread().getName(), magic, timestamp.toString());
    }
178443
public static void deleteFileOrDirectory(File file) {
    if (!file.isDirectory()) {
      file.delete();
      return;
    }

    if (file.list().length == 0) { //Nothing under directory. Just delete it.
      file.delete();
      return;
    }

    for (String temp : file.list()) { //Delete files or directory under current directory.
      File fileDelete = new File(file, temp);
      deleteFileOrDirectory(fileDelete);
    }
    //Now there is nothing under directory, delete it.
    deleteFileOrDirectory(file);
  }
323672
function( file ) {
                var me = this,
                    existing = this._map[ file.id ];
    
                if ( existing ) {
                    delete this._map[ file.id ];
                    file.destroy();
                    this.stats.numofDeleted++;
                }
            }
600757
public static function Delete( string $file )
   {

      if ( ! \file_exists( $file ) )
      {
         // No deleting required
         return;
      }

      try
      {
         \unlink( $file );
         \clearstatcache();
         if ( ! \file_exists( $file ) )
         {
            // Deleting was successful
            return;
         }
      }
      catch ( \Throwable $ex ) { }

      if ( '\\' === DIRECTORY_SEPARATOR )
      {
         $f = \escapeshellarg( $file );
         try { \exec( "del {$f}" ); }
         catch ( \Throwable $ex )
         {
            throw new IOException( $file, 'Deleting the defined file fails!', \E_USER_ERROR, $ex );
         }
         \clearstatcache();
         if ( \file_exists( $file ) )
         {
            throw new IOException(
               $file,
               'Deleting the defined file fails! No known method works.'
            );
         }
         return;
      }

      try { \exec( "unlink {$file}" ); }
      catch ( \Throwable $ex )
      {
         throw new IOException( $file, 'Deleting the defined file fails!', \E_USER_ERROR, $ex );
      }

      \clearstatcache();

      if ( \file_exists( $file ) )
      {
         throw new IOException(
            $file,
            'Deleting the defined file fails!'
         );
      }

   }
545359
public void deleteFile(long id) throws IOException {
        if (id >= getFileCount()) {
            return;
        }

        Long key = new Long(id);
        InternalFile file = openInternal(key);

        // Acquire write lock on file to delete before acquiring lock on
        // file table. This ensures a consistent lock order with all other
        // operations and prevents deadlock. Operations on internal files
        // will first lock the internal file, and then lock the shared file
        // table when necessary.
        try {
            file.lock().acquireWriteLock();
            // Use the file table lock to prevent multiple threads from using
            // mOpenFiles.
            try {
                mFileTableLock.acquireWriteLock();
                file.delete();
                mOpenFiles.remove(key);
            }
            finally {
                mFileTableLock.releaseLock();
            }
        }
        catch (InterruptedException e) {
            throw new InterruptedIOException();
        }
        finally {
            file.lock().releaseLock();
        }
    }