In case we cannot delete a directory create a marker to recheck whether we can garbage collect some not
referenced directories and files.

@param file the directory
558654
protected void failedToCleanupDir(final File file) {
        checkForGarbageOnRestart = true;
        PatchLogger.ROOT_LOGGER.cannotDeleteFile(file.getAbsolutePath());
    }
427534
private static void deleteOldFile(final File file) {
		if (!file.exists()) {
			return;
		}

		LOG.debug("删除旧文件：{}", file);
		boolean success = file.delete();
		if (!success) {
			LOG.warn("删除文件失败：{}", file);
		}
	}
838830
public static void deleteDirectory(File directory) throws IOException {
    requireNonNull(directory, DIRECTORY_CAN_NOT_BE_NULL);
    deleteDirectoryImpl(directory.toPath());
  }
479491
private void processDirectory(File directory) throws IOException, ClassNotFoundException {

        findFiles(directory);
        File[] files = directory.listFiles();
        if (files != null) {
            for (File file : files) {
                if (file.isDirectory()) {
                    processDirectory(file);
                }
            }
        }
    }
701158
public void setFile(String file) {

        if (file != null) {
            m_file = file.toLowerCase();
        } else {
            m_file = null;
        }
    }
559719
public static boolean deleteFile(File file) {
        if (file.exists()) {
            if (file.isDirectory()) {
                try {
                    deleteDirectory(file);
                    return true;
                } catch (IOException e) {
                    logger.error(e.getMessage());
                    return false;
                }
            } else {
                return file.delete();
            }
        }
        return false;
    }
42409
@Deprecated
	public static void newParentDirectories(final File file)
	{
		if (!file.exists())
		{
			final File parent = file.getParentFile();
			if (parent != null && !parent.exists())
			{
				parent.mkdirs();
			}
		}
	}
844437
public static void cleanDirectory(File directory) throws IOException {
    requireNonNull(directory, DIRECTORY_CAN_NOT_BE_NULL);

    Path path = directory.toPath();
    if (!path.toFile().exists()) {
      return;
    }

    cleanDirectoryImpl(path);
  }
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();
  }
560753
public void addOutputFile(String file) {
        if (file != null) {
            File f = new File(file);
            if (f.isDirectory()) {
                throw new IllegalArgumentException("output file parameter points to a directory, must be a file");
            } else if (f.exists() && !f.canWrite()) {
                throw new IllegalArgumentException(
                        "output file parameter points to a file we have no write permissions");
            }

            setOutputFile(f);
        }
    }
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;
   }
851261
private static void checkFile(File file) {
		if (false == file.exists()) {
			throw new UtilException("File [{}] not exist !", file.getAbsolutePath());
		}
		if (false == file.isFile()) {
			throw new UtilException("Path [{}] is not a file !", file.getAbsolutePath());
		}
	}
1370088
public synchronized void remove(final File file) {
        final T t = cache.get(file);
        expiry.remove(file);
        cache.remove(file);
        if (null != t && t instanceof Expireable) {
            final Expireable exp = (Expireable) t;
            exp.expire();
        }
    }
709909
public static boolean deleteOrDie(@Nonnull final String file) throws IOException {
        // this returns true if the file was actually deleted
        // and false for 2 cases:
        //   1. file did not exist to start with
        //   2. File.delete() failed at some point for some reason
        // so we disambiguate the 'false' case below by checking for file existence
        final boolean fileWasDeleted = delete(file);

        if (fileWasDeleted) {
            // file was definitely deleted
            return true;
        } else {
            final File fileObj = new File(file);
            if (fileObj.exists()) {
                throw new IOException("File still exists after erasure, cannot write object to file: " + file);
            }

            // file was not deleted, because it does not exist
            return false;
        }
    }
829206
public static void deleteFile(File file)
    {
        Check.notNull(file);

        try
        {
            Files.delete(file.toPath());
        }
        catch (final IOException exception)
        {
            throw new LionEngineException(exception, ERROR_DELETE_FILE + file.getAbsolutePath());
        }
    }
108124
public static void mkParentDirs(final File file) throws IOException {
        // Create parent directory structure if necessary
        File parentFile = file.getParentFile();
        if (parentFile == null) {
            // File was created with a relative path
            parentFile = file.getAbsoluteFile().getParentFile();
        }
        if (parentFile != null && !parentFile.exists()) {
            if (!parentFile.mkdirs()) {
                throw new IOException("Unable to create parent directory " +
                        "structure for file " + file.getAbsolutePath());
            }
        }
    }
867367
private void doDelete(java.io.File file)
    {
        // Make the directory to write the objects to.
        if (file.isDirectory()) {

            // Find all of the files in the next level.

            // JCLRM does not have listFiles...
            // java.io.File nextFiles[] = file.listFiles();

            String[] files = file.list();
            java.io.File[] nextFiles = null;
            if (files != null) {
                nextFiles = new java.io.File[files.length];
                for (int iFile = 0; iFile < nextFiles.length; iFile++) {
                    nextFiles[iFile] = new java.io.File(file.getPath(),
                                                        files[iFile]);
                }
            }

            if (nextFiles != null) {
                for (int iFile = 0; // Index to next files.
                iFile < nextFiles.length; iFile++) {
                    java.io.File nextFile = nextFiles[iFile];
                    if (nextFile.isDirectory()) {
                        doDelete(nextFile);
                    } else {
                        nextFile.delete();
                    }
                } // for loop over existing Files.
            }
        } // if (file.isDirectory()).
        file.delete();
    }