View Javadoc
1   /*
2    * Copyright (C) 2014 The Guava Authors
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package com.google.common.io;
18  
19  import com.google.common.annotations.Beta;
20  import com.google.common.annotations.GwtIncompatible;
21  import com.google.j2objc.annotations.J2ObjCIncompatible;
22  import java.nio.file.SecureDirectoryStream;
23  
24  /**
25   * Options for use with recursive delete methods ({@link MoreFiles#deleteRecursively} and
26   * {@link MoreFiles#deleteDirectoryContents}).
27   *
28   * @since 21.0
29   * @author Colin Decker
30   */
31  @Beta
32  @GwtIncompatible
33  @J2ObjCIncompatible // java.nio.file
34  public enum RecursiveDeleteOption {
35    /**
36     * Specifies that the recursive delete should not throw an exception when it can't be guaranteed
37     * that it can be done securely, without vulnerability to race conditions (i.e. when the file
38     * system does not support {@link SecureDirectoryStream}).
39     *
40     * <p><b>Warning:</b> On a file system that supports symbolic links, it is possible for an
41     * insecure recursive delete to delete files and directories that are <i>outside</i> the
42     * directory being deleted. This can happen if, after checking that a file is a directory (and
43     * not a symbolic link), that directory is deleted and replaced by a symbolic link to an outside
44     * directory before the call that opens the directory to read its entries. File systems that
45     * support {@code SecureDirectoryStream} do not have this vulnerability.
46     */
47    ALLOW_INSECURE
48  }