• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2014 Google Inc.
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.jimfs;
18 
19 import java.nio.channels.AsynchronousFileChannel;
20 import java.nio.channels.FileChannel;
21 import java.nio.channels.SeekableByteChannel;
22 import java.nio.file.DirectoryStream;
23 import java.nio.file.Files;
24 import java.nio.file.OpenOption;
25 import java.nio.file.Path;
26 import java.nio.file.SecureDirectoryStream;
27 import java.nio.file.attribute.FileAttribute;
28 import java.util.Set;
29 import java.util.concurrent.ExecutorService;
30 
31 /**
32  * Optional file system features that may be supported or unsupported by a Jimfs file system
33  * instance.
34  *
35  * @author Colin Decker
36  */
37 public enum Feature {
38 
39   /**
40    * Feature controlling support for hard links to regular files.
41    *
42    * <p>Affected method:
43    *
44    * <ul>
45    *   <li>{@link Files#createLink(Path, Path)}
46    * </ul>
47    *
48    * <p>If this feature is not enabled, this method will throw {@link
49    * UnsupportedOperationException}.
50    */
51   LINKS,
52 
53   /**
54    * Feature controlling support for symbolic links.
55    *
56    * <p>Affected methods:
57    *
58    * <ul>
59    *   <li>{@link Files#createSymbolicLink(Path, Path, FileAttribute...)}
60    *   <li>{@link Files#readSymbolicLink(Path)}
61    * </ul>
62    *
63    * <p>If this feature is not enabled, these methods will throw {@link
64    * UnsupportedOperationException}.
65    */
66   SYMBOLIC_LINKS,
67 
68   /**
69    * Feature controlling support for {@link SecureDirectoryStream}.
70    *
71    * <p>Affected methods:
72    *
73    * <ul>
74    *   <li>{@link Files#newDirectoryStream(Path)}
75    *   <li>{@link Files#newDirectoryStream(Path, DirectoryStream.Filter)}
76    *   <li>{@link Files#newDirectoryStream(Path, String)}
77    * </ul>
78    *
79    * <p>If this feature is enabled, the {@link DirectoryStream} instances returned by these methods
80    * will also implement {@link SecureDirectoryStream}.
81    */
82   SECURE_DIRECTORY_STREAM,
83 
84   /**
85    * Feature controlling support for {@link FileChannel}.
86    *
87    * <p>Affected methods:
88    *
89    * <ul>
90    *   <li>{@link Files#newByteChannel(Path, OpenOption...)}
91    *   <li>{@link Files#newByteChannel(Path, Set, FileAttribute...)}
92    *   <li>{@link FileChannel#open(Path, OpenOption...)}
93    *   <li>{@link FileChannel#open(Path, Set, FileAttribute...)}
94    *   <li>{@link AsynchronousFileChannel#open(Path, OpenOption...)}
95    *   <li>{@link AsynchronousFileChannel#open(Path, Set, ExecutorService, FileAttribute...)}
96    * </ul>
97    *
98    * <p>If this feature is not enabled, the {@link SeekableByteChannel} instances returned by the
99    * {@code Files} methods will not be {@code FileChannel} instances and the {@code
100    * FileChannel.open} and {@code AsynchronousFileChannel.open} methods will throw {@link
101    * UnsupportedOperationException}.
102    */
103   // TODO(cgdecker): Should support for AsynchronousFileChannel be a separate feature?
104   FILE_CHANNEL
105 }
106