• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 {@link
26  * MoreFiles#deleteDirectoryContents}).
27  *
28  * @since 21.0
29  * @author Colin Decker
30  */
31 @Beta
32 @GwtIncompatible
33 @J2ObjCIncompatible // java.nio.file
34 @ElementTypesAreNonnullByDefault
35 public enum RecursiveDeleteOption {
36   /**
37    * Specifies that the recursive delete should not throw an exception when it can't be guaranteed
38    * that it can be done securely, without vulnerability to race conditions (i.e. when the file
39    * system does not support {@link SecureDirectoryStream}).
40    *
41    * <p><b>Warning:</b> On a file system that supports symbolic links, it is possible for an
42    * insecure recursive delete to delete files and directories that are <i>outside</i> the directory
43    * being deleted. This can happen if, after checking that a file is a directory (and not a
44    * symbolic link), that directory is deleted and replaced by a symbolic link to an outside
45    * directory before the call that opens the directory to read its entries. File systems that
46    * support {@code SecureDirectoryStream} do not have this vulnerability.
47    */
48   ALLOW_INSECURE
49 }
50