001/*
002 * Copyright (C) 2014 The Guava Authors
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package com.google.common.io;
018
019import com.google.common.annotations.GwtIncompatible;
020import com.google.common.annotations.J2ktIncompatible;
021import com.google.j2objc.annotations.J2ObjCIncompatible;
022import java.nio.file.SecureDirectoryStream;
023
024/**
025 * Options for use with recursive delete methods ({@link MoreFiles#deleteRecursively} and {@link
026 * MoreFiles#deleteDirectoryContents}).
027 *
028 * @since 33.4.0 (but since 21.0 in the JRE flavor)
029 * @author Colin Decker
030 */
031@J2ktIncompatible
032@GwtIncompatible
033@J2ObjCIncompatible // java.nio.file
034public enum RecursiveDeleteOption {
035  /**
036   * Specifies that the recursive delete should not throw an exception when it can't be guaranteed
037   * that it can be done securely, without vulnerability to race conditions (i.e. when the file
038   * system does not support {@link SecureDirectoryStream}).
039   *
040   * <p><b>Warning:</b> On a file system that supports symbolic links, it is possible for an
041   * insecure recursive delete to delete files and directories that are <i>outside</i> the directory
042   * being deleted. This can happen if, after checking that a file is a directory (and not a
043   * symbolic link), that directory is deleted and replaced by a symbolic link to an outside
044   * directory before the call that opens the directory to read its entries. File systems that
045   * support {@code SecureDirectoryStream} do not have this vulnerability.
046   */
047  ALLOW_INSECURE
048}