aboutsummaryrefslogtreecommitdiff
path: root/jimfs/src/main
diff options
context:
space:
mode:
authorColin Decker <cgdecker@google.com>2014-01-22 15:26:28 -0800
committerColin Decker <cgdecker@google.com>2014-01-22 15:26:28 -0800
commit65b50e08ca79dcf145a4397ec0522f7904e2621b (patch)
treefb0a75eee915622bbba877b3455b2f8b03365ba2 /jimfs/src/main
parentf841812c09e36a4e909e385e5352a87ca89ceff8 (diff)
downloadjimfs-65b50e08ca79dcf145a4397ec0522f7904e2621b.tar.gz
Collapse all packages into com.google.jimfs.
Make some things package private that weren't before and fold Inode into File, making AttributeProvider and its implementations work with Files rather than Inodes.
Diffstat (limited to 'jimfs/src/main')
-rw-r--r--jimfs/src/main/java/com/google/jimfs/AbstractAttributeView.java (renamed from jimfs/src/main/java/com/google/jimfs/attribute/AbstractAttributeView.java)10
-rw-r--r--jimfs/src/main/java/com/google/jimfs/AbstractWatchService.java (renamed from jimfs/src/main/java/com/google/jimfs/internal/AbstractWatchService.java)2
-rw-r--r--jimfs/src/main/java/com/google/jimfs/AclAttributeProvider.java (renamed from jimfs/src/main/java/com/google/jimfs/attribute/AclAttributeProvider.java)18
-rw-r--r--jimfs/src/main/java/com/google/jimfs/AttributeProvider.java (renamed from jimfs/src/main/java/com/google/jimfs/attribute/AttributeProvider.java)26
-rw-r--r--jimfs/src/main/java/com/google/jimfs/AttributeService.java (renamed from jimfs/src/main/java/com/google/jimfs/internal/AttributeService.java)94
-rw-r--r--jimfs/src/main/java/com/google/jimfs/BasicAttributeProvider.java (renamed from jimfs/src/main/java/com/google/jimfs/attribute/BasicAttributeProvider.java)66
-rw-r--r--jimfs/src/main/java/com/google/jimfs/BlockList.java (renamed from jimfs/src/main/java/com/google/jimfs/internal/BlockList.java)6
-rw-r--r--jimfs/src/main/java/com/google/jimfs/ByteStore.java (renamed from jimfs/src/main/java/com/google/jimfs/internal/ByteStore.java)2
-rw-r--r--jimfs/src/main/java/com/google/jimfs/Configuration.java151
-rw-r--r--jimfs/src/main/java/com/google/jimfs/DirectoryEntry.java (renamed from jimfs/src/main/java/com/google/jimfs/internal/DirectoryEntry.java)2
-rw-r--r--jimfs/src/main/java/com/google/jimfs/DirectoryEntryMap.java (renamed from jimfs/src/main/java/com/google/jimfs/internal/DirectoryEntryMap.java)2
-rw-r--r--jimfs/src/main/java/com/google/jimfs/DirectoryTable.java (renamed from jimfs/src/main/java/com/google/jimfs/internal/DirectoryTable.java)13
-rw-r--r--jimfs/src/main/java/com/google/jimfs/DosAttributeProvider.java (renamed from jimfs/src/main/java/com/google/jimfs/attribute/DosAttributeProvider.java)40
-rw-r--r--jimfs/src/main/java/com/google/jimfs/File.java (renamed from jimfs/src/main/java/com/google/jimfs/attribute/Inode.java)143
-rw-r--r--jimfs/src/main/java/com/google/jimfs/FileContent.java (renamed from jimfs/src/main/java/com/google/jimfs/internal/FileContent.java)2
-rw-r--r--jimfs/src/main/java/com/google/jimfs/FileFactory.java (renamed from jimfs/src/main/java/com/google/jimfs/internal/FileFactory.java)2
-rw-r--r--jimfs/src/main/java/com/google/jimfs/FileLookup.java (renamed from jimfs/src/main/java/com/google/jimfs/path/package-info.java)21
-rw-r--r--jimfs/src/main/java/com/google/jimfs/FileSystemView.java (renamed from jimfs/src/main/java/com/google/jimfs/internal/FileSystemView.java)7
-rw-r--r--jimfs/src/main/java/com/google/jimfs/FileTree.java (renamed from jimfs/src/main/java/com/google/jimfs/internal/FileTree.java)2
-rw-r--r--jimfs/src/main/java/com/google/jimfs/GlobToRegex.java (renamed from jimfs/src/main/java/com/google/jimfs/internal/GlobToRegex.java)2
-rw-r--r--jimfs/src/main/java/com/google/jimfs/HeapDisk.java (renamed from jimfs/src/main/java/com/google/jimfs/internal/HeapDisk.java)11
-rw-r--r--jimfs/src/main/java/com/google/jimfs/InternalCharMatcher.java (renamed from jimfs/src/main/java/com/google/jimfs/internal/InternalCharMatcher.java)2
-rw-r--r--jimfs/src/main/java/com/google/jimfs/Jimfs.java1
-rw-r--r--jimfs/src/main/java/com/google/jimfs/JimfsAsynchronousFileChannel.java (renamed from jimfs/src/main/java/com/google/jimfs/internal/JimfsAsynchronousFileChannel.java)15
-rw-r--r--jimfs/src/main/java/com/google/jimfs/JimfsDirectoryStream.java (renamed from jimfs/src/main/java/com/google/jimfs/internal/JimfsDirectoryStream.java)2
-rw-r--r--jimfs/src/main/java/com/google/jimfs/JimfsFileChannel.java (renamed from jimfs/src/main/java/com/google/jimfs/internal/JimfsFileChannel.java)28
-rw-r--r--jimfs/src/main/java/com/google/jimfs/JimfsFileStore.java (renamed from jimfs/src/main/java/com/google/jimfs/internal/JimfsFileStore.java)5
-rw-r--r--jimfs/src/main/java/com/google/jimfs/JimfsFileSystem.java357
-rw-r--r--jimfs/src/main/java/com/google/jimfs/JimfsFileSystemProvider.java (renamed from jimfs/src/main/java/com/google/jimfs/internal/JimfsFileSystemProvider.java)10
-rw-r--r--jimfs/src/main/java/com/google/jimfs/JimfsFileSystems.java (renamed from jimfs/src/main/java/com/google/jimfs/internal/JimfsFileSystems.java)8
-rw-r--r--jimfs/src/main/java/com/google/jimfs/JimfsInputStream.java (renamed from jimfs/src/main/java/com/google/jimfs/internal/JimfsInputStream.java)2
-rw-r--r--jimfs/src/main/java/com/google/jimfs/JimfsOutputStream.java (renamed from jimfs/src/main/java/com/google/jimfs/internal/JimfsOutputStream.java)2
-rw-r--r--jimfs/src/main/java/com/google/jimfs/JimfsPath.java (renamed from jimfs/src/main/java/com/google/jimfs/internal/JimfsPath.java)16
-rw-r--r--jimfs/src/main/java/com/google/jimfs/JimfsSecureDirectoryStream.java (renamed from jimfs/src/main/java/com/google/jimfs/internal/JimfsSecureDirectoryStream.java)8
-rw-r--r--jimfs/src/main/java/com/google/jimfs/Name.java (renamed from jimfs/src/main/java/com/google/jimfs/internal/Name.java)5
-rw-r--r--jimfs/src/main/java/com/google/jimfs/Options.java (renamed from jimfs/src/main/java/com/google/jimfs/internal/Options.java)2
-rw-r--r--jimfs/src/main/java/com/google/jimfs/OwnerAttributeProvider.java (renamed from jimfs/src/main/java/com/google/jimfs/attribute/OwnerAttributeProvider.java)20
-rw-r--r--jimfs/src/main/java/com/google/jimfs/PathMatchers.java (renamed from jimfs/src/main/java/com/google/jimfs/internal/PathMatchers.java)9
-rw-r--r--jimfs/src/main/java/com/google/jimfs/PathNormalization.java (renamed from jimfs/src/main/java/com/google/jimfs/path/Normalization.java)19
-rw-r--r--jimfs/src/main/java/com/google/jimfs/PathService.java (renamed from jimfs/src/main/java/com/google/jimfs/internal/PathService.java)27
-rw-r--r--jimfs/src/main/java/com/google/jimfs/PathType.java (renamed from jimfs/src/main/java/com/google/jimfs/path/PathType.java)2
-rw-r--r--jimfs/src/main/java/com/google/jimfs/PollingWatchService.java (renamed from jimfs/src/main/java/com/google/jimfs/internal/PollingWatchService.java)4
-rw-r--r--jimfs/src/main/java/com/google/jimfs/PosixAttributeProvider.java (renamed from jimfs/src/main/java/com/google/jimfs/attribute/PosixAttributeProvider.java)45
-rw-r--r--jimfs/src/main/java/com/google/jimfs/ResourceManager.java (renamed from jimfs/src/main/java/com/google/jimfs/internal/ResourceManager.java)2
-rw-r--r--jimfs/src/main/java/com/google/jimfs/StandardAttributeProviders.java (renamed from jimfs/src/main/java/com/google/jimfs/attribute/StandardAttributeProviders.java)4
-rw-r--r--jimfs/src/main/java/com/google/jimfs/UnixAttributeProvider.java (renamed from jimfs/src/main/java/com/google/jimfs/attribute/UnixAttributeProvider.java)22
-rw-r--r--jimfs/src/main/java/com/google/jimfs/UnixFileAttributeView.java (renamed from jimfs/src/main/java/com/google/jimfs/attribute/UnixFileAttributeView.java)2
-rw-r--r--jimfs/src/main/java/com/google/jimfs/UnixPathType.java (renamed from jimfs/src/main/java/com/google/jimfs/path/UnixPathType.java)2
-rw-r--r--jimfs/src/main/java/com/google/jimfs/UserDefinedAttributeProvider.java (renamed from jimfs/src/main/java/com/google/jimfs/attribute/UserDefinedAttributeProvider.java)30
-rw-r--r--jimfs/src/main/java/com/google/jimfs/UserLookupService.java (renamed from jimfs/src/main/java/com/google/jimfs/internal/UserLookupService.java)4
-rw-r--r--jimfs/src/main/java/com/google/jimfs/UserPrincipals.java (renamed from jimfs/src/main/java/com/google/jimfs/attribute/UserPrincipals.java)2
-rw-r--r--jimfs/src/main/java/com/google/jimfs/Util.java (renamed from jimfs/src/main/java/com/google/jimfs/internal/Util.java)2
-rw-r--r--jimfs/src/main/java/com/google/jimfs/WindowsPathType.java (renamed from jimfs/src/main/java/com/google/jimfs/path/WindowsPathType.java)2
-rw-r--r--jimfs/src/main/java/com/google/jimfs/attribute/package-info.java33
-rw-r--r--jimfs/src/main/java/com/google/jimfs/internal/File.java109
-rw-r--r--jimfs/src/main/java/com/google/jimfs/internal/JimfsFileSystem.java224
-rw-r--r--jimfs/src/main/java/com/google/jimfs/internal/package-info.java158
-rw-r--r--jimfs/src/main/resources/META-INF/services/java.nio.file.spi.FileSystemProvider2
58 files changed, 782 insertions, 1027 deletions
diff --git a/jimfs/src/main/java/com/google/jimfs/attribute/AbstractAttributeView.java b/jimfs/src/main/java/com/google/jimfs/AbstractAttributeView.java
index c88e7ca..7a336c8 100644
--- a/jimfs/src/main/java/com/google/jimfs/attribute/AbstractAttributeView.java
+++ b/jimfs/src/main/java/com/google/jimfs/AbstractAttributeView.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.attribute;
+package com.google.jimfs;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -28,16 +28,16 @@ import java.nio.file.attribute.FileAttributeView;
*/
abstract class AbstractAttributeView implements FileAttributeView {
- private final Inode.Lookup lookup;
+ private final FileLookup lookup;
- protected AbstractAttributeView(Inode.Lookup lookup) {
+ protected AbstractAttributeView(FileLookup lookup) {
this.lookup = checkNotNull(lookup);
}
/**
- * Gets the inode object to get or set attributes on.
+ * Looks up the file to get or set attributes on.
*/
- protected final Inode lookupInode() throws IOException {
+ protected final File lookupFile() throws IOException {
return lookup.lookup();
}
}
diff --git a/jimfs/src/main/java/com/google/jimfs/internal/AbstractWatchService.java b/jimfs/src/main/java/com/google/jimfs/AbstractWatchService.java
index b947c3c..17ef33a 100644
--- a/jimfs/src/main/java/com/google/jimfs/internal/AbstractWatchService.java
+++ b/jimfs/src/main/java/com/google/jimfs/AbstractWatchService.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.internal;
+package com.google.jimfs;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
diff --git a/jimfs/src/main/java/com/google/jimfs/attribute/AclAttributeProvider.java b/jimfs/src/main/java/com/google/jimfs/AclAttributeProvider.java
index f284fd8..fc686dc 100644
--- a/jimfs/src/main/java/com/google/jimfs/attribute/AclAttributeProvider.java
+++ b/jimfs/src/main/java/com/google/jimfs/AclAttributeProvider.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.attribute;
+package com.google.jimfs;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -75,9 +75,9 @@ final class AclAttributeProvider extends AttributeProvider {
@Nullable
@Override
- public Object get(Inode inode, String attribute) {
+ public Object get(File file, String attribute) {
if (attribute.equals("acl")) {
- return inode.getAttribute("acl", "acl");
+ return file.getAttribute("acl", "acl");
}
return null;
@@ -85,10 +85,10 @@ final class AclAttributeProvider extends AttributeProvider {
@Override
public void set(
- Inode inode, String view, String attribute, Object value, boolean create) {
+ File file, String view, String attribute, Object value, boolean create) {
if (attribute.equals("acl")) {
checkNotCreate(view, attribute, create);
- inode.setAttribute("acl", "acl", toAcl(checkType(view, attribute, value, List.class)));
+ file.setAttribute("acl", "acl", toAcl(checkType(view, attribute, value, List.class)));
}
}
@@ -111,7 +111,7 @@ final class AclAttributeProvider extends AttributeProvider {
}
@Override
- public AclFileAttributeView view(Inode.Lookup lookup,
+ public AclFileAttributeView view(FileLookup lookup,
ImmutableMap<String, FileAttributeView> inheritedViews) {
return new View(lookup, (FileOwnerAttributeView) inheritedViews.get("owner"));
}
@@ -123,7 +123,7 @@ final class AclAttributeProvider extends AttributeProvider {
private final FileOwnerAttributeView ownerView;
- public View(Inode.Lookup lookup, FileOwnerAttributeView ownerView) {
+ public View(FileLookup lookup, FileOwnerAttributeView ownerView) {
super(lookup);
this.ownerView = checkNotNull(ownerView);
}
@@ -136,13 +136,13 @@ final class AclAttributeProvider extends AttributeProvider {
@SuppressWarnings("unchecked")
@Override
public List<AclEntry> getAcl() throws IOException {
- return (List<AclEntry>) lookupInode().getAttribute("acl", "acl");
+ return (List<AclEntry>) lookupFile().getAttribute("acl", "acl");
}
@Override
public void setAcl(List<AclEntry> acl) throws IOException {
checkNotNull(acl);
- lookupInode().setAttribute("acl", "acl", ImmutableList.copyOf(acl));
+ lookupFile().setAttribute("acl", "acl", ImmutableList.copyOf(acl));
}
@Override
diff --git a/jimfs/src/main/java/com/google/jimfs/attribute/AttributeProvider.java b/jimfs/src/main/java/com/google/jimfs/AttributeProvider.java
index 01dcf5c..a3e6794 100644
--- a/jimfs/src/main/java/com/google/jimfs/attribute/AttributeProvider.java
+++ b/jimfs/src/main/java/com/google/jimfs/AttributeProvider.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.attribute;
+package com.google.jimfs;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -29,7 +29,7 @@ import java.util.Map;
import javax.annotation.Nullable;
/**
- * Provider for handling a specific file attribute view.
+ * Abstract provider for handling a specific file attribute view.
*
* @author Colin Decker
*/
@@ -53,11 +53,11 @@ public abstract class AttributeProvider {
public abstract Class<? extends FileAttributeView> viewType();
/**
- * Returns a view of the inode located by the given lookup callback. The given map
- * contains the views inherited by this view.
+ * Returns a view of the file located by the given lookup callback. The given map contains the
+ * views inherited by this view.
*/
public abstract FileAttributeView view(
- Inode.Lookup lookup, ImmutableMap<String, FileAttributeView> inheritedViews);
+ FileLookup lookup, ImmutableMap<String, FileAttributeView> inheritedViews);
/**
* Returns a map containing the default attribute values for this provider. The keys of the map
@@ -88,22 +88,22 @@ public abstract class AttributeProvider {
}
/**
- * Returns the set of attributes supported by this view that are present in the given inode. For
+ * Returns the set of attributes supported by this view that are present in the given file. For
* most providers, this will be a fixed set of attributes.
*/
- public ImmutableSet<String> attributes(Inode inode) {
+ public ImmutableSet<String> attributes(File file) {
return fixedAttributes();
}
/**
- * Returns the value of the given attribute in the given inode or null if the attribute is not
+ * Returns the value of the given attribute in the given file or null if the attribute is not
* supported by this provider.
*/
@Nullable
- public abstract Object get(Inode inode, String attribute);
+ public abstract Object get(File file, String attribute);
/**
- * Sets the value of the given attribute in the given inode object. The {@code create}
+ * Sets the value of the given attribute in the given file object. The {@code create}
* parameter indicates whether or not the value is being set upon creation of a new file via a
* user-provided {@code FileAttribute}.
*
@@ -113,7 +113,7 @@ public abstract class AttributeProvider {
* and is allowed to be set by the user, but not on file creation and {@code create} is true
*/
public abstract void set(
- Inode inode, String view, String attribute, Object value, boolean create);
+ File file, String view, String attribute, Object value, boolean create);
// optional
@@ -127,12 +127,12 @@ public abstract class AttributeProvider {
}
/**
- * Reads this provider's attributes from the given inode as an attributes object.
+ * Reads this provider's attributes from the given file as an attributes object.
*
* @throws UnsupportedOperationException if this provider does not support reading an attributes
* object
*/
- public BasicFileAttributes readAttributes(Inode inode) {
+ public BasicFileAttributes readAttributes(File file) {
throw new UnsupportedOperationException();
}
diff --git a/jimfs/src/main/java/com/google/jimfs/internal/AttributeService.java b/jimfs/src/main/java/com/google/jimfs/AttributeService.java
index f2bc3ab..8787775 100644
--- a/jimfs/src/main/java/com/google/jimfs/internal/AttributeService.java
+++ b/jimfs/src/main/java/com/google/jimfs/AttributeService.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.internal;
+package com.google.jimfs;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -22,10 +22,6 @@ import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
-import com.google.jimfs.Configuration;
-import com.google.jimfs.attribute.AttributeProvider;
-import com.google.jimfs.attribute.Inode;
-import com.google.jimfs.attribute.StandardAttributeProviders;
import java.nio.file.FileStore;
import java.nio.file.FileSystem;
@@ -64,7 +60,7 @@ final class AttributeService {
* Creates a new attribute service using the given configuration.
*/
public AttributeService(Configuration configuration) {
- this(getProviders(configuration), configuration.defaultAttributeValues());
+ this(getProviders(configuration), configuration.defaultAttributeValues);
}
/**
@@ -103,11 +99,11 @@ final class AttributeService {
private static Iterable<AttributeProvider> getProviders(Configuration configuration) {
Map<String, AttributeProvider> result = new HashMap<>();
- for (AttributeProvider provider : configuration.attributeProviders()) {
+ for (AttributeProvider provider : configuration.attributeProviders) {
result.put(provider.name(), provider);
}
- for (String view : configuration.attributeViews()) {
+ for (String view : configuration.attributeViews) {
addStandardProvider(result, view);
}
@@ -166,9 +162,9 @@ final class AttributeService {
}
/**
- * Sets all initial attributes for the given inode, including the given attributes if possible.
+ * Sets all initial attributes for the given file, including the given attributes if possible.
*/
- public void setInitialAttributes(Inode inode, FileAttribute<?>... attrs) {
+ public void setInitialAttributes(File file, FileAttribute<?>... attrs) {
// default values should already be sanitized by their providers
for (int i = 0; i < defaultValues.size(); i++) {
FileAttribute<?> attribute = defaultValues.get(i);
@@ -176,45 +172,45 @@ final class AttributeService {
int separatorIndex = attribute.name().indexOf(':');
String view = attribute.name().substring(0, separatorIndex);
String attr = attribute.name().substring(separatorIndex + 1);
- inode.setAttribute(view, attr, attribute.value());
+ file.setAttribute(view, attr, attribute.value());
}
for (FileAttribute<?> attr : attrs) {
- setAttribute(inode, attr.name(), attr.value(), true);
+ setAttribute(file, attr.name(), attr.value(), true);
}
}
/**
- * Copies the file times of the given inode to the given copy inode.
+ * Copies the file times of the given file to the given copy file.
*/
- public void copyBasicAttributes(Inode inode, Inode copy) {
- inode.copyBasicAttributes(copy);
+ public void copyBasicAttributes(File file, File copy) {
+ file.copyBasicAttributes(copy);
}
/**
- * Copies the attributes of the given inode to the given copy inode.
+ * Copies the attributes of the given file to the given copy file.
*/
- public void copyAttributes(Inode inode, Inode copy) {
- inode.copyAttributes(copy);
+ public void copyAttributes(File file, File copy) {
+ file.copyAttributes(copy);
}
/**
- * Gets the value of the given attribute for the given inode. {@code attribute} must be of the
+ * Gets the value of the given attribute for the given file. {@code attribute} must be of the
* form "view:attribute" or "attribute".
*/
- public <V> V getAttribute(Inode inode, String attribute) {
+ public <V> V getAttribute(File file, String attribute) {
String view = getViewName(attribute);
String attr = getSingleAttribute(attribute);
- return getAttribute(inode, view, attr);
+ return getAttribute(file, view, attr);
}
/**
- * Gets the value of the given attribute for the given view and inode. Neither view nor attribute
+ * Gets the value of the given attribute for the given view and file. Neither view nor attribute
* may have a ':' character.
*/
@SuppressWarnings("unchecked")
- public <V> V getAttribute(Inode inode, String view, String attribute) {
- Object value = getAttributeInternal(inode, view, attribute);
+ public <V> V getAttribute(File file, String view, String attribute) {
+ Object value = getAttributeInternal(file, view, attribute);
if (value == null) {
throw new IllegalArgumentException(
"invalid attribute for view '" + view + "': " + attribute);
@@ -223,16 +219,16 @@ final class AttributeService {
}
@Nullable
- private Object getAttributeInternal(Inode inode, String view, String attribute) {
+ private Object getAttributeInternal(File file, String view, String attribute) {
AttributeProvider provider = providersByName.get(view);
if (provider == null) {
return null;
}
- Object value = provider.get(inode, attribute);
+ Object value = provider.get(file, attribute);
if (value == null) {
for (String inheritedView : provider.inherits()) {
- value = getAttributeInternal(inode, inheritedView, attribute);
+ value = getAttributeInternal(file, inheritedView, attribute);
if (value != null) {
break;
}
@@ -243,28 +239,28 @@ final class AttributeService {
}
/**
- * Sets the value of the given attribute to the given value for the given inode.
+ * Sets the value of the given attribute to the given value for the given file.
*/
- public void setAttribute(Inode inode, String attribute, Object value, boolean create) {
+ public void setAttribute(File file, String attribute, Object value, boolean create) {
String view = getViewName(attribute);
String attr = getSingleAttribute(attribute);
- setAttributeInternal(inode, view, attr, value, create);
+ setAttributeInternal(file, view, attr, value, create);
}
private void setAttributeInternal(
- Inode inode, String view, String attribute, Object value, boolean create) {
+ File file, String view, String attribute, Object value, boolean create) {
AttributeProvider provider = providersByName.get(view);
if (provider != null) {
if (provider.supports(attribute)) {
- provider.set(inode, view, attribute, value, create);
+ provider.set(file, view, attribute, value, create);
return;
}
for (String inheritedView : provider.inherits()) {
AttributeProvider inheritedProvider = providersByName.get(inheritedView);
if (inheritedProvider.supports(attribute)) {
- inheritedProvider.set(inode, view, attribute, value, create);
+ inheritedProvider.set(file, view, attribute, value, create);
return;
}
}
@@ -274,13 +270,13 @@ final class AttributeService {
}
/**
- * Returns an attribute view of the given type for the given inode lookup callback, or
+ * Returns an attribute view of the given type for the given file lookup callback, or
* {@code null} if the view type is not supported.
*/
@SuppressWarnings("unchecked")
@Nullable
public <V extends FileAttributeView> V getFileAttributeView(
- Inode.Lookup lookup, Class<V> type) {
+ FileLookup lookup, Class<V> type) {
AttributeProvider provider = providersByViewType.get(type);
if (provider != null) {
@@ -291,7 +287,7 @@ final class AttributeService {
}
private ImmutableMap<String, FileAttributeView> createInheritedViews(
- Inode.Lookup lookup, AttributeProvider provider) {
+ FileLookup lookup, AttributeProvider provider) {
if (provider.inherits().isEmpty()) {
return ImmutableMap.of();
}
@@ -301,7 +297,7 @@ final class AttributeService {
return ImmutableMap.copyOf(inheritedViews);
}
- private void createInheritedViews(Inode.Lookup lookup, AttributeProvider provider,
+ private void createInheritedViews(FileLookup lookup, AttributeProvider provider,
Map<String, FileAttributeView> inheritedViews) {
for (String inherited : provider.inherits()) {
@@ -315,7 +311,7 @@ final class AttributeService {
}
}
- private FileAttributeView getFileAttributeView(Inode.Lookup lookup,
+ private FileAttributeView getFileAttributeView(FileLookup lookup,
Class<? extends FileAttributeView> viewType, Map<String, FileAttributeView> inheritedViews) {
AttributeProvider provider = providersByViewType.get(viewType);
createInheritedViews(lookup, provider, inheritedViews);
@@ -325,7 +321,7 @@ final class AttributeService {
/**
* Implements {@link Files#readAttributes(Path, String, LinkOption...)}.
*/
- public ImmutableMap<String, Object> readAttributes(Inode inode, String attributes) {
+ public ImmutableMap<String, Object> readAttributes(File file, String attributes) {
String view = getViewName(attributes);
List<String> attrs = getAttributeNames(attributes);
@@ -338,28 +334,28 @@ final class AttributeService {
if (attrs.size() == 1 && attrs.contains(ALL_ATTRIBUTES)) {
// for 'view:*' format, get all keys for all providers for the view
AttributeProvider provider = providersByName.get(view);
- readAll(inode, provider, result);
+ readAll(file, provider, result);
for (String inheritedView : provider.inherits()) {
AttributeProvider inheritedProvider = providersByName.get(inheritedView);
- readAll(inode, inheritedProvider, result);
+ readAll(file, inheritedProvider, result);
}
} else {
// for 'view:attr1,attr2,etc'
for (String attr : attrs) {
- result.put(attr, getAttribute(inode, view, attr));
+ result.put(attr, getAttribute(file, view, attr));
}
}
return ImmutableMap.copyOf(result);
}
- private static void readAll(Inode inode, AttributeProvider provider, Map<String, Object> map) {
- for (String attribute : provider.attributes(inode)) {
- Object value = provider.get(inode, attribute);
+ private static void readAll(File file, AttributeProvider provider, Map<String, Object> map) {
+ for (String attribute : provider.attributes(file)) {
+ Object value = provider.get(file, attribute);
// check for null to protect against race condition when an attribute present when
- // attributes(inode) was called is deleted before get() is called for that attribute
+ // attributes(file) was called is deleted before get() is called for that attribute
if (value != null) {
map.put(attribute, value);
}
@@ -367,15 +363,15 @@ final class AttributeService {
}
/**
- * Returns attributes of the given inode as an object of the given type.
+ * Returns attributes of the given file as an object of the given type.
*
* @throws UnsupportedOperationException if the given attributes type is not supported
*/
@SuppressWarnings("unchecked")
- public <A extends BasicFileAttributes> A readAttributes(Inode inode, Class<A> type) {
+ public <A extends BasicFileAttributes> A readAttributes(File file, Class<A> type) {
AttributeProvider provider = providersByAttributesType.get(type);
if (provider != null) {
- return (A) provider.readAttributes(inode);
+ return (A) provider.readAttributes(file);
}
throw new UnsupportedOperationException("unsupported attributes type: " + type);
diff --git a/jimfs/src/main/java/com/google/jimfs/attribute/BasicAttributeProvider.java b/jimfs/src/main/java/com/google/jimfs/BasicAttributeProvider.java
index 96f2315..55d0382 100644
--- a/jimfs/src/main/java/com/google/jimfs/attribute/BasicAttributeProvider.java
+++ b/jimfs/src/main/java/com/google/jimfs/BasicAttributeProvider.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.attribute;
+package com.google.jimfs;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
@@ -58,47 +58,47 @@ final class BasicAttributeProvider extends AttributeProvider {
}
@Override
- public Object get(Inode inode, String attribute) {
+ public Object get(File file, String attribute) {
switch (attribute) {
case "size":
- return inode.size();
+ return file.size();
case "fileKey":
- return inode.id();
+ return file.id();
case "isDirectory":
- return inode.isDirectory();
+ return file.isDirectory();
case "isRegularFile":
- return inode.isRegularFile();
+ return file.isRegularFile();
case "isSymbolicLink":
- return inode.isSymbolicLink();
+ return file.isSymbolicLink();
case "isOther":
- return !inode.isDirectory() && !inode.isRegularFile() && !inode.isSymbolicLink();
+ return !file.isDirectory() && !file.isRegularFile() && !file.isSymbolicLink();
case "creationTime":
- return FileTime.fromMillis(inode.getCreationTime());
+ return FileTime.fromMillis(file.getCreationTime());
case "lastAccessTime":
- return FileTime.fromMillis(inode.getLastAccessTime());
+ return FileTime.fromMillis(file.getLastAccessTime());
case "lastModifiedTime":
- return FileTime.fromMillis(inode.getLastModifiedTime());
+ return FileTime.fromMillis(file.getLastModifiedTime());
default:
return null;
}
}
@Override
- public void set(Inode inode,
+ public void set(File file,
String view, String attribute, Object value, boolean create) {
switch (attribute) {
case "creationTime":
checkNotCreate(view, attribute, create);
- inode.setCreationTime(
+ file.setCreationTime(
checkType(view, attribute, value, FileTime.class).toMillis());
break;
case "lastAccessTime":
checkNotCreate(view, attribute, create);
- inode.setLastAccessTime(checkType(view, attribute, value, FileTime.class).toMillis());
+ file.setLastAccessTime(checkType(view, attribute, value, FileTime.class).toMillis());
break;
case "lastModifiedTime":
checkNotCreate(view, attribute, create);
- inode.setLastModifiedTime(checkType(view, attribute, value, FileTime.class).toMillis());
+ file.setLastModifiedTime(checkType(view, attribute, value, FileTime.class).toMillis());
break;
case "size":
case "fileKey":
@@ -117,7 +117,7 @@ final class BasicAttributeProvider extends AttributeProvider {
}
@Override
- public BasicFileAttributeView view(Inode.Lookup lookup,
+ public BasicFileAttributeView view(FileLookup lookup,
ImmutableMap<String, FileAttributeView> inheritedViews) {
return new View(lookup);
}
@@ -128,8 +128,8 @@ final class BasicAttributeProvider extends AttributeProvider {
}
@Override
- public BasicFileAttributes readAttributes(Inode inode) {
- return new Attributes(inode);
+ public BasicFileAttributes readAttributes(File file) {
+ return new Attributes(file);
}
/**
@@ -137,7 +137,7 @@ final class BasicAttributeProvider extends AttributeProvider {
*/
private static final class View extends AbstractAttributeView implements BasicFileAttributeView {
- protected View(Inode.Lookup lookup) {
+ protected View(FileLookup lookup) {
super(lookup);
}
@@ -148,7 +148,7 @@ final class BasicAttributeProvider extends AttributeProvider {
@Override
public BasicFileAttributes readAttributes() throws IOException {
- return new Attributes(lookupInode());
+ return new Attributes(lookupFile());
}
@Override
@@ -156,18 +156,18 @@ final class BasicAttributeProvider extends AttributeProvider {
@Nullable FileTime lastModifiedTime,
@Nullable FileTime lastAccessTime,
@Nullable FileTime createTime) throws IOException {
- Inode inode = lookupInode();
+ File file = lookupFile();
if (lastModifiedTime != null) {
- inode.setLastModifiedTime(lastModifiedTime.toMillis());
+ file.setLastModifiedTime(lastModifiedTime.toMillis());
}
if (lastAccessTime != null) {
- inode.setLastAccessTime(lastAccessTime.toMillis());
+ file.setLastAccessTime(lastAccessTime.toMillis());
}
if (createTime != null) {
- inode.setCreationTime(createTime.toMillis());
+ file.setCreationTime(createTime.toMillis());
}
}
}
@@ -186,15 +186,15 @@ final class BasicAttributeProvider extends AttributeProvider {
private final long size;
private final Object fileKey;
- protected Attributes(Inode inode) {
- this.lastModifiedTime = FileTime.fromMillis(inode.getLastModifiedTime());
- this.lastAccessTime = FileTime.fromMillis(inode.getLastAccessTime());
- this.creationTime = FileTime.fromMillis(inode.getCreationTime());
- this.regularFile = inode.isRegularFile();
- this.directory = inode.isDirectory();
- this.symbolicLink = inode.isSymbolicLink();
- this.size = inode.size();
- this.fileKey = inode.id();
+ protected Attributes(File file) {
+ this.lastModifiedTime = FileTime.fromMillis(file.getLastModifiedTime());
+ this.lastAccessTime = FileTime.fromMillis(file.getLastAccessTime());
+ this.creationTime = FileTime.fromMillis(file.getCreationTime());
+ this.regularFile = file.isRegularFile();
+ this.directory = file.isDirectory();
+ this.symbolicLink = file.isSymbolicLink();
+ this.size = file.size();
+ this.fileKey = file.id();
}
@Override
diff --git a/jimfs/src/main/java/com/google/jimfs/internal/BlockList.java b/jimfs/src/main/java/com/google/jimfs/BlockList.java
index 338d0ea..abf0435 100644
--- a/jimfs/src/main/java/com/google/jimfs/internal/BlockList.java
+++ b/jimfs/src/main/java/com/google/jimfs/BlockList.java
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-package com.google.jimfs.internal;
+package com.google.jimfs;
-import static com.google.jimfs.internal.Util.clear;
-import static com.google.jimfs.internal.Util.nextPowerOf2;
+import static com.google.jimfs.Util.clear;
+import static com.google.jimfs.Util.nextPowerOf2;
import java.util.Arrays;
diff --git a/jimfs/src/main/java/com/google/jimfs/internal/ByteStore.java b/jimfs/src/main/java/com/google/jimfs/ByteStore.java
index 9fd41ac..0070cb7 100644
--- a/jimfs/src/main/java/com/google/jimfs/internal/ByteStore.java
+++ b/jimfs/src/main/java/com/google/jimfs/ByteStore.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.internal;
+package com.google.jimfs;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
diff --git a/jimfs/src/main/java/com/google/jimfs/Configuration.java b/jimfs/src/main/java/com/google/jimfs/Configuration.java
index d1e68fc..c87484b 100644
--- a/jimfs/src/main/java/com/google/jimfs/Configuration.java
+++ b/jimfs/src/main/java/com/google/jimfs/Configuration.java
@@ -18,19 +18,14 @@ package com.google.jimfs;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.jimfs.path.Normalization.CASE_FOLD_ASCII;
-import static com.google.jimfs.path.Normalization.NFC;
-import static com.google.jimfs.path.Normalization.NFD;
+import static com.google.jimfs.PathNormalization.CASE_FOLD_ASCII;
+import static com.google.jimfs.PathNormalization.NFC;
+import static com.google.jimfs.PathNormalization.NFD;
-import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
-import com.google.jimfs.attribute.AttributeProvider;
-import com.google.jimfs.attribute.StandardAttributeProviders;
-import com.google.jimfs.path.Normalization;
-import com.google.jimfs.path.PathType;
import java.nio.file.FileSystem;
import java.nio.file.InvalidPathException;
@@ -182,24 +177,24 @@ public final class Configuration {
}
// Path configuration
- private final PathType pathType;
- private final ImmutableSet<Normalization> nameDisplayNormalization;
- private final ImmutableSet<Normalization> nameCanonicalNormalization;
- private final boolean pathEqualityUsesCanonicalForm;
+ final PathType pathType;
+ final ImmutableSet<PathNormalization> nameDisplayNormalization;
+ final ImmutableSet<PathNormalization> nameCanonicalNormalization;
+ final boolean pathEqualityUsesCanonicalForm;
// Disk configuration
- private final int blockSize;
- private final long maxSize;
- private final long maxCacheSize;
+ final int blockSize;
+ final long maxSize;
+ final long maxCacheSize;
// Attribute configuration
- private final ImmutableSet<String> attributeViews;
- private final ImmutableSet<AttributeProvider> attributeProviders;
- private final ImmutableMap<String, Object> defaultAttributeValues;
+ final ImmutableSet<String> attributeViews;
+ final ImmutableSet<AttributeProvider> attributeProviders;
+ final ImmutableMap<String, Object> defaultAttributeValues;
// Other
- private final ImmutableSet<String> roots;
- private final String workingDirectory;
+ final ImmutableSet<String> roots;
+ final String workingDirectory;
/**
* Creates an immutable configuration object from the given builder.
@@ -224,102 +219,6 @@ public final class Configuration {
}
/**
- * Returns the roots for the file system.
- */
- public ImmutableList<String> roots() {
- return ImmutableList.copyOf(roots);
- }
-
- /**
- * Returns the working directory for the file system.
- */
- public String workingDirectory() {
- return workingDirectory;
- }
-
- /**
- * Returns the path type for the file system.
- */
- public PathType pathType() {
- return pathType;
- }
-
- /**
- * Returns the normalizations that will be applied to filenames for the string form of
- * {@code Path} objects in the file system.
- */
- public ImmutableSet<Normalization> nameDisplayNormalization() {
- return nameDisplayNormalization;
- }
-
- /**
- * Returns the normalizations that will be applied to the canonical form of filenames in the file
- * system.
- */
- public ImmutableSet<Normalization> nameCanonicalNormalization() {
- return nameCanonicalNormalization;
- }
-
- /**
- * Returns true if {@code Path} objects in the file system use the canonical form of filenames
- * for determining equality of two paths; false if they use the display form.
- */
- public boolean pathEqualityUsesCanonicalForm() {
- return pathEqualityUsesCanonicalForm;
- }
-
- /**
- * Returns the block size (in bytes) for the file system to use. All regular files will be
- * allocated blocks of the given size, so this is the minimum granularity for actual file size.
- */
- public int blockSize() {
- return blockSize;
- }
-
- /**
- * Returns the maximum size (in bytes) for the file system's in-memory file storage. This maximum
- * size determines the maximum number of blocks that can be allocated to regular files, so it
- * should generally be a multiple of the {@linkplain #blockSize() block size}.
- */
- public long maxSize() {
- return maxSize;
- }
-
- /**
- * Returns the maximum amount of unused space (in bytes) in the file system's in-memory file
- * storage that should be cached for reuse. By default, this will be equal to the
- * {@linkplain #maxSize() maximum size} of the storage, meaning that all space that is freed
- * when files are truncated or deleted is cached for reuse. This helps to avoid lots of garbage
- * collection when creating and deleting many files quickly.
- */
- public long maxCacheSize() {
- return maxCacheSize;
- }
-
- /**
- * Returns the set of file attribute views the file system supports.
- */
- public ImmutableSet<String> attributeViews() {
- return attributeViews;
- }
-
- /**
- * Returns the set of custom attribute providers the file system uses to implement custom file
- * attribute views.
- */
- public ImmutableSet<AttributeProvider> attributeProviders() {
- return attributeProviders;
- }
-
- /**
- * Returns the set of default file attribute values for the file system. The values in the
- * returned map override the file system defaults.
- */
- public ImmutableMap<String, Object> defaultAttributeValues() {
- return defaultAttributeValues;
- }
-
- /**
* Returns a new mutable builder that initially contains the same settings as this configuration.
*/
public Builder toBuilder() {
@@ -342,8 +241,8 @@ public final class Configuration {
// Path configuration
private final PathType pathType;
- private ImmutableSet<Normalization> nameDisplayNormalization = ImmutableSet.of();
- private ImmutableSet<Normalization> nameCanonicalNormalization = ImmutableSet.of();
+ private ImmutableSet<PathNormalization> nameDisplayNormalization = ImmutableSet.of();
+ private ImmutableSet<PathNormalization> nameCanonicalNormalization = ImmutableSet.of();
private boolean pathEqualityUsesCanonicalForm = false;
// Disk configuration
@@ -387,7 +286,7 @@ public final class Configuration {
* Sets the normalizations that will be applied to the display form of filenames. The display
* form is used in the {@code toString()} of {@code Path} objects.
*/
- public Builder setNameDisplayNormalization(Normalization first, Normalization... more) {
+ public Builder setNameDisplayNormalization(PathNormalization first, PathNormalization... more) {
this.nameDisplayNormalization = checkNormalizations(Lists.asList(first, more));
return this;
}
@@ -397,16 +296,16 @@ public final class Configuration {
* file system. The canonical form is used to determine the equality of two filenames when
* performing a file lookup.
*/
- public Builder setNameCanonicalNormalization(Normalization first, Normalization... more) {
+ public Builder setNameCanonicalNormalization(PathNormalization first, PathNormalization... more) {
this.nameCanonicalNormalization = checkNormalizations(Lists.asList(first, more));
return this;
}
- private ImmutableSet<Normalization> checkNormalizations(List<Normalization> normalizations) {
- Normalization none = null;
- Normalization normalization = null;
- Normalization caseFold = null;
- for (Normalization n : normalizations) {
+ private ImmutableSet<PathNormalization> checkNormalizations(List<PathNormalization> normalizations) {
+ PathNormalization none = null;
+ PathNormalization normalization = null;
+ PathNormalization caseFold = null;
+ for (PathNormalization n : normalizations) {
checkNotNull(n);
checkNormalizationNotSet(n, none);
@@ -435,7 +334,7 @@ public final class Configuration {
return Sets.immutableEnumSet(normalizations);
}
- private static void checkNormalizationNotSet(Normalization n, @Nullable Normalization set) {
+ private static void checkNormalizationNotSet(PathNormalization n, @Nullable PathNormalization set) {
if (set != null) {
throw new IllegalArgumentException("can't set normalization " + n
+ ": normalization " + set + " already set");
diff --git a/jimfs/src/main/java/com/google/jimfs/internal/DirectoryEntry.java b/jimfs/src/main/java/com/google/jimfs/DirectoryEntry.java
index d387e18..2d70705 100644
--- a/jimfs/src/main/java/com/google/jimfs/internal/DirectoryEntry.java
+++ b/jimfs/src/main/java/com/google/jimfs/DirectoryEntry.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.internal;
+package com.google.jimfs;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
diff --git a/jimfs/src/main/java/com/google/jimfs/internal/DirectoryEntryMap.java b/jimfs/src/main/java/com/google/jimfs/DirectoryEntryMap.java
index 9d3f64e..6b2dfcd 100644
--- a/jimfs/src/main/java/com/google/jimfs/internal/DirectoryEntryMap.java
+++ b/jimfs/src/main/java/com/google/jimfs/DirectoryEntryMap.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.internal;
+package com.google.jimfs;
import com.google.common.collect.AbstractIterator;
diff --git a/jimfs/src/main/java/com/google/jimfs/internal/DirectoryTable.java b/jimfs/src/main/java/com/google/jimfs/DirectoryTable.java
index 394acf5..d20bbba 100644
--- a/jimfs/src/main/java/com/google/jimfs/internal/DirectoryTable.java
+++ b/jimfs/src/main/java/com/google/jimfs/DirectoryTable.java
@@ -14,10 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.internal;
-
-import static com.google.jimfs.internal.Name.PARENT;
-import static com.google.jimfs.internal.Name.SELF;
+package com.google.jimfs;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableSortedSet;
@@ -104,8 +101,8 @@ final class DirectoryTable implements FileContent {
@Override
public void linked(DirectoryEntry entry) {
this.entryInParent = entry;
- map.put(new DirectoryEntry(entry.file(), SELF, entry.file()));
- map.put(new DirectoryEntry(entry.file(), PARENT, entry.directory()));
+ map.put(new DirectoryEntry(entry.file(), Name.SELF, entry.file()));
+ map.put(new DirectoryEntry(entry.file(), Name.PARENT, entry.directory()));
}
/**
@@ -113,8 +110,8 @@ final class DirectoryTable implements FileContent {
*/
@Override
public void unlinked() {
- map.remove(SELF);
- map.remove(PARENT);
+ map.remove(Name.SELF);
+ map.remove(Name.PARENT);
entryInParent = null;
}
diff --git a/jimfs/src/main/java/com/google/jimfs/attribute/DosAttributeProvider.java b/jimfs/src/main/java/com/google/jimfs/DosAttributeProvider.java
index af994c3..425198b 100644
--- a/jimfs/src/main/java/com/google/jimfs/attribute/DosAttributeProvider.java
+++ b/jimfs/src/main/java/com/google/jimfs/DosAttributeProvider.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.attribute;
+package com.google.jimfs;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -83,20 +83,20 @@ final class DosAttributeProvider extends AttributeProvider {
@Nullable
@Override
- public Object get(Inode inode, String attribute) {
+ public Object get(File file, String attribute) {
if (ATTRIBUTES.contains(attribute)) {
- return inode.getAttribute("dos", attribute);
+ return file.getAttribute("dos", attribute);
}
return null;
}
@Override
- public void set(Inode inode, String view, String attribute, Object value,
+ public void set(File file, String view, String attribute, Object value,
boolean create) {
if (supports(attribute)) {
checkNotCreate(view, attribute, create);
- inode.setAttribute("dos", attribute, checkType(view, attribute, value, Boolean.class));
+ file.setAttribute("dos", attribute, checkType(view, attribute, value, Boolean.class));
}
}
@@ -106,7 +106,7 @@ final class DosAttributeProvider extends AttributeProvider {
}
@Override
- public DosFileAttributeView view(Inode.Lookup lookup,
+ public DosFileAttributeView view(FileLookup lookup,
ImmutableMap<String, FileAttributeView> inheritedViews) {
return new View(lookup, (BasicFileAttributeView) inheritedViews.get("basic"));
}
@@ -117,8 +117,8 @@ final class DosAttributeProvider extends AttributeProvider {
}
@Override
- public DosFileAttributes readAttributes(Inode inode) {
- return new Attributes(inode);
+ public DosFileAttributes readAttributes(File file) {
+ return new Attributes(file);
}
/**
@@ -128,7 +128,7 @@ final class DosAttributeProvider extends AttributeProvider {
private final BasicFileAttributeView basicView;
- public View(Inode.Lookup lookup, BasicFileAttributeView basicView) {
+ public View(FileLookup lookup, BasicFileAttributeView basicView) {
super(lookup);
this.basicView = checkNotNull(basicView);
}
@@ -140,7 +140,7 @@ final class DosAttributeProvider extends AttributeProvider {
@Override
public DosFileAttributes readAttributes() throws IOException {
- return new Attributes(lookupInode());
+ return new Attributes(lookupFile());
}
@Override
@@ -151,22 +151,22 @@ final class DosAttributeProvider extends AttributeProvider {
@Override
public void setReadOnly(boolean value) throws IOException {
- lookupInode().setAttribute("dos", "readonly", value);
+ lookupFile().setAttribute("dos", "readonly", value);
}
@Override
public void setHidden(boolean value) throws IOException {
- lookupInode().setAttribute("dos", "hidden", value);
+ lookupFile().setAttribute("dos", "hidden", value);
}
@Override
public void setSystem(boolean value) throws IOException {
- lookupInode().setAttribute("dos", "system", value);
+ lookupFile().setAttribute("dos", "system", value);
}
@Override
public void setArchive(boolean value) throws IOException {
- lookupInode().setAttribute("dos", "archive", value);
+ lookupFile().setAttribute("dos", "archive", value);
}
}
@@ -180,12 +180,12 @@ final class DosAttributeProvider extends AttributeProvider {
private final boolean archive;
private final boolean system;
- protected Attributes(Inode inode) {
- super(inode);
- this.readOnly = (boolean) inode.getAttribute("dos", "readonly");
- this.hidden = (boolean) inode.getAttribute("dos", "hidden");
- this.archive = (boolean) inode.getAttribute("dos", "archive");
- this.system = (boolean) inode.getAttribute("dos", "system");
+ protected Attributes(File file) {
+ super(file);
+ this.readOnly = (boolean) file.getAttribute("dos", "readonly");
+ this.hidden = (boolean) file.getAttribute("dos", "hidden");
+ this.archive = (boolean) file.getAttribute("dos", "archive");
+ this.system = (boolean) file.getAttribute("dos", "system");
}
@Override
diff --git a/jimfs/src/main/java/com/google/jimfs/attribute/Inode.java b/jimfs/src/main/java/com/google/jimfs/File.java
index 6679370..4c24925 100644
--- a/jimfs/src/main/java/com/google/jimfs/attribute/Inode.java
+++ b/jimfs/src/main/java/com/google/jimfs/File.java
@@ -14,24 +14,24 @@
* limitations under the License.
*/
-package com.google.jimfs.attribute;
+package com.google.jimfs;
+
+import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Objects;
import com.google.common.collect.HashBasedTable;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Table;
-import java.io.IOException;
-
import javax.annotation.Nullable;
/**
- * Object for storing file metadata. Conceptually similar to a UNIX
- * <a href="http://en.wikipedia.org/wiki/Inode">inode</a>.
+ * A file object, containing both the file's metadata and a reference to its content.
*
* @author Colin Decker
*/
-public abstract class Inode {
+public final class File {
private final int id;
@@ -44,116 +44,164 @@ public abstract class Inode {
@Nullable // null when only the basic view is used (default)
private Table<String, String, Object> attributes;
- protected Inode(int id) {
+ private final FileContent content;
+
+ File(int id, FileContent content) {
this.id = id;
long now = System.currentTimeMillis(); // TODO(cgdecker): Use a Clock
this.creationTime = now;
this.lastAccessTime = now;
this.lastModifiedTime = now;
+ this.content = checkNotNull(content);
}
/**
- * Returns the ID of this inode.
+ * Returns the ID of this file.
*/
- public final int id() {
+ public int id() {
return id;
}
/**
- * Returns whether or not the file this inode represents is a directory.
+ * Returns the content of this file.
*/
- public abstract boolean isDirectory();
+ FileContent content() {
+ return content;
+ }
/**
- * Returns whether or not the file this inode represents is a regular file.
+ * Returns the size, in bytes, of this file's content. Directories and symbolic links have a size
+ * of 0.
*/
- public abstract boolean isRegularFile();
+ public long size() {
+ return content.size();
+ }
/**
- * Returns whether or not the file is this inode represents a symbolic link.
+ * Returns whether or not this file is a directory.
*/
- public abstract boolean isSymbolicLink();
+ public boolean isDirectory() {
+ return content instanceof DirectoryTable;
+ }
/**
- * Returns the size, in bytes, of the content of the file this inode represents.
+ * Returns whether or not this file is a regular file.
*/
- public abstract long size();
+ public boolean isRegularFile() {
+ return content instanceof ByteStore;
+ }
+
+ /**
+ * Returns whether or not this file is a symbolic link.
+ */
+ public boolean isSymbolicLink() {
+ return content instanceof JimfsPath;
+ }
+
+ /**
+ * Returns whether or not this file is a root directory of the file system.
+ */
+ boolean isRootDirectory() {
+ // only root directories have their parent link pointing to themselves
+ return isDirectory() && equals(asDirectory().parent());
+ }
/**
- * Returns the current count of links to this inode.
+ * Returns a view of this file as a byte store.
*/
- public final synchronized int links() {
+ ByteStore asBytes() {
+ return (ByteStore) content;
+ }
+
+ /**
+ * Returns a view of this file as a directory table.
+ */
+ DirectoryTable asDirectory() {
+ return (DirectoryTable) content;
+ }
+
+ /**
+ * Gets the target of this symbolic link.
+ */
+ public JimfsPath asTargetPath() {
+ return (JimfsPath) content;
+ }
+
+ /**
+ * Returns the current count of links to this file.
+ */
+ public synchronized int links() {
return links;
}
/**
* Increments the link count.
*/
- public final synchronized void incrementLinkCount() {
+ synchronized void incrementLinkCount() {
links++;
}
/**
* Decrements and returns the link count.
*/
- public final synchronized int decrementLinkCount() {
+ synchronized int decrementLinkCount() {
return --links;
}
/**
* Gets the creation time of the file.
*/
- public final synchronized long getCreationTime() {
+ public synchronized long getCreationTime() {
return creationTime;
}
/**
* Gets the last access time of the file.
*/
- public final synchronized long getLastAccessTime() {
+ public synchronized long getLastAccessTime() {
return lastAccessTime;
}
/**
* Gets the last modified time of the file.
*/
- public final synchronized long getLastModifiedTime() {
+ public synchronized long getLastModifiedTime() {
return lastModifiedTime;
}
/**
* Sets the creation time of the file.
*/
- public final synchronized void setCreationTime(long creationTime) {
+ synchronized void setCreationTime(long creationTime) {
this.creationTime = creationTime;
}
/**
* Sets the last access time of the file.
*/
- public final synchronized void setLastAccessTime(long lastAccessTime) {
+ synchronized void setLastAccessTime(long lastAccessTime) {
this.lastAccessTime = lastAccessTime;
}
/**
* Sets the last modified time of the file.
*/
- public final synchronized void setLastModifiedTime(long lastModifiedTime) {
+ synchronized void setLastModifiedTime(long lastModifiedTime) {
this.lastModifiedTime = lastModifiedTime;
}
/**
* Sets the last access time of the file to the current time.
*/
- public final void updateAccessTime() {
+ void updateAccessTime() {
setLastAccessTime(System.currentTimeMillis());
}
/**
* Sets the last modified time of the file to the current time.
*/
- public final void updateModifiedTime() {
+ void updateModifiedTime() {
setLastModifiedTime(System.currentTimeMillis());
}
@@ -161,7 +209,7 @@ public abstract class Inode {
* Returns the names of the attributes contained in the given attribute view in the file's
* attributes table.
*/
- public final synchronized ImmutableSet<String> getAttributeNames(String view) {
+ public synchronized ImmutableSet<String> getAttributeNames(String view) {
if (attributes == null) {
return ImmutableSet.of();
}
@@ -172,7 +220,7 @@ public abstract class Inode {
* Returns the attribute keys contained in the attributes map for the file.
*/
@VisibleForTesting
- final synchronized ImmutableSet<String> getAttributeKeys() {
+ synchronized ImmutableSet<String> getAttributeKeys() {
if (attributes == null) {
return ImmutableSet.of();
}
@@ -188,7 +236,7 @@ public abstract class Inode {
* Gets the value of the given attribute in the given view.
*/
@Nullable
- public final synchronized Object getAttribute(String view, String attribute) {
+ public synchronized Object getAttribute(String view, String attribute) {
if (attributes == null) {
return null;
}
@@ -198,7 +246,7 @@ public abstract class Inode {
/**
* Sets the given attribute in the given view to the given value.
*/
- public final synchronized void setAttribute(String view, String attribute, Object value) {
+ public synchronized void setAttribute(String view, String attribute, Object value) {
if (attributes == null) {
attributes = HashBasedTable.create();
}
@@ -208,16 +256,16 @@ public abstract class Inode {
/**
* Deletes the given attribute from the given view.
*/
- public final synchronized void deleteAttribute(String view, String attribute) {
+ public synchronized void deleteAttribute(String view, String attribute) {
if (attributes != null) {
attributes.remove(view, attribute);
}
}
/**
- * Copies basic attributes (file times) from this inode to the given inode.
+ * Copies basic attributes (file times) from this file to the given file.
*/
- public final synchronized void copyBasicAttributes(Inode target) {
+ synchronized void copyBasicAttributes(File target) {
target.setFileTimes(creationTime, lastModifiedTime, lastAccessTime);
}
@@ -229,9 +277,9 @@ public abstract class Inode {
}
/**
- * Copies the attributes from this inode to the given inode.
+ * Copies the attributes from this file to the given file.
*/
- public final synchronized void copyAttributes(Inode target) {
+ synchronized void copyAttributes(File target) {
copyBasicAttributes(target);
target.putAll(attributes);
}
@@ -245,18 +293,11 @@ public abstract class Inode {
}
}
- /**
- * Callback for looking up an inode.
- *
- * @author Colin Decker
- */
- public interface Lookup {
-
- /**
- * Looks up the inode.
- *
- * @throws IOException if the lookup fails for any reason, such as the file not existing
- */
- Inode lookup() throws IOException;
+ @Override
+ public String toString() {
+ return Objects.toStringHelper(this)
+ .add("id", id())
+ .add("contentType", content.getClass().getSimpleName())
+ .toString();
}
}
diff --git a/jimfs/src/main/java/com/google/jimfs/internal/FileContent.java b/jimfs/src/main/java/com/google/jimfs/FileContent.java
index 6fb013e..317ea57 100644
--- a/jimfs/src/main/java/com/google/jimfs/internal/FileContent.java
+++ b/jimfs/src/main/java/com/google/jimfs/FileContent.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.internal;
+package com.google.jimfs;
import java.io.IOException;
import java.nio.file.CopyOption;
diff --git a/jimfs/src/main/java/com/google/jimfs/internal/FileFactory.java b/jimfs/src/main/java/com/google/jimfs/FileFactory.java
index 9869981..11f81fa 100644
--- a/jimfs/src/main/java/com/google/jimfs/internal/FileFactory.java
+++ b/jimfs/src/main/java/com/google/jimfs/FileFactory.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.internal;
+package com.google.jimfs;
import static com.google.common.base.Preconditions.checkNotNull;
diff --git a/jimfs/src/main/java/com/google/jimfs/path/package-info.java b/jimfs/src/main/java/com/google/jimfs/FileLookup.java
index 33c3a5e..f1e4fd4 100644
--- a/jimfs/src/main/java/com/google/jimfs/path/package-info.java
+++ b/jimfs/src/main/java/com/google/jimfs/FileLookup.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 Google Inc.
+ * Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,10 +14,21 @@
* limitations under the License.
*/
+package com.google.jimfs;
+
+import java.io.IOException;
+
/**
- * Package containing classes used for configuration of paths and file names in a file system.
+ * Callback for looking up a file.
+ *
+ * @author Colin Decker
*/
-@ParametersAreNonnullByDefault
-package com.google.jimfs.path;
+public interface FileLookup {
-import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file
+ /**
+ * Looks up the file.
+ *
+ * @throws IOException if the lookup fails for any reason, such as the file not existing
+ */
+ File lookup() throws IOException;
+}
diff --git a/jimfs/src/main/java/com/google/jimfs/internal/FileSystemView.java b/jimfs/src/main/java/com/google/jimfs/FileSystemView.java
index fe6c5f8..7bedf76 100644
--- a/jimfs/src/main/java/com/google/jimfs/internal/FileSystemView.java
+++ b/jimfs/src/main/java/com/google/jimfs/FileSystemView.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.internal;
+package com.google.jimfs;
import static com.google.common.base.Preconditions.checkNotNull;
import static java.nio.file.StandardCopyOption.COPY_ATTRIBUTES;
@@ -29,7 +29,6 @@ import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSortedSet;
import com.google.common.collect.Lists;
-import com.google.jimfs.attribute.Inode;
import java.io.IOException;
import java.nio.file.CopyOption;
@@ -646,9 +645,9 @@ final class FileSystemView {
@Nullable
public <V extends FileAttributeView> V getFileAttributeView(
final JimfsPath path, Class<V> type, final Set<? super LinkOption> options) {
- return store.getFileAttributeView(new Inode.Lookup() {
+ return store.getFileAttributeView(new FileLookup() {
@Override
- public Inode lookup() throws IOException {
+ public File lookup() throws IOException {
return lookUpWithLock(path, options)
.requireExists(path)
.file();
diff --git a/jimfs/src/main/java/com/google/jimfs/internal/FileTree.java b/jimfs/src/main/java/com/google/jimfs/FileTree.java
index e9d8800..e4178c7 100644
--- a/jimfs/src/main/java/com/google/jimfs/internal/FileTree.java
+++ b/jimfs/src/main/java/com/google/jimfs/FileTree.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.internal;
+package com.google.jimfs;
import static com.google.common.base.Preconditions.checkNotNull;
diff --git a/jimfs/src/main/java/com/google/jimfs/internal/GlobToRegex.java b/jimfs/src/main/java/com/google/jimfs/GlobToRegex.java
index 6ade12e..98424bf 100644
--- a/jimfs/src/main/java/com/google/jimfs/internal/GlobToRegex.java
+++ b/jimfs/src/main/java/com/google/jimfs/GlobToRegex.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.internal;
+package com.google.jimfs;
import static com.google.common.base.Preconditions.checkNotNull;
diff --git a/jimfs/src/main/java/com/google/jimfs/internal/HeapDisk.java b/jimfs/src/main/java/com/google/jimfs/HeapDisk.java
index da7d767..a9b9a65 100644
--- a/jimfs/src/main/java/com/google/jimfs/internal/HeapDisk.java
+++ b/jimfs/src/main/java/com/google/jimfs/HeapDisk.java
@@ -14,13 +14,12 @@
* limitations under the License.
*/
-package com.google.jimfs.internal;
+package com.google.jimfs;
import static com.google.common.base.Preconditions.checkArgument;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.math.LongMath;
-import com.google.jimfs.Configuration;
import java.io.IOException;
import java.math.RoundingMode;
@@ -55,11 +54,11 @@ final class HeapDisk {
* Creates a new disk using settings from the given configuration.
*/
public HeapDisk(Configuration config) {
- this.blockSize = config.blockSize();
- this.maxBlockCount = toBlockCount(config.maxSize(), blockSize);
- this.maxCachedBlockCount = config.maxCacheSize() == -1
+ this.blockSize = config.blockSize;
+ this.maxBlockCount = toBlockCount(config.maxSize, blockSize);
+ this.maxCachedBlockCount = config.maxCacheSize == -1
? maxBlockCount
- : toBlockCount(config.maxCacheSize(), blockSize);
+ : toBlockCount(config.maxCacheSize, blockSize);
this.blockCache = new BlockList(Math.min(maxCachedBlockCount, 8192));
}
diff --git a/jimfs/src/main/java/com/google/jimfs/internal/InternalCharMatcher.java b/jimfs/src/main/java/com/google/jimfs/InternalCharMatcher.java
index b929249..da20235 100644
--- a/jimfs/src/main/java/com/google/jimfs/internal/InternalCharMatcher.java
+++ b/jimfs/src/main/java/com/google/jimfs/InternalCharMatcher.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.internal;
+package com.google.jimfs;
import java.util.Arrays;
diff --git a/jimfs/src/main/java/com/google/jimfs/Jimfs.java b/jimfs/src/main/java/com/google/jimfs/Jimfs.java
index 44e2e5d..ebc7ef7 100644
--- a/jimfs/src/main/java/com/google/jimfs/Jimfs.java
+++ b/jimfs/src/main/java/com/google/jimfs/Jimfs.java
@@ -20,7 +20,6 @@ import static com.google.common.base.Preconditions.checkArgument;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableMap;
-import com.google.jimfs.path.PathType;
import java.io.IOException;
import java.net.URI;
diff --git a/jimfs/src/main/java/com/google/jimfs/internal/JimfsAsynchronousFileChannel.java b/jimfs/src/main/java/com/google/jimfs/JimfsAsynchronousFileChannel.java
index 060c28e..46a0ea3 100644
--- a/jimfs/src/main/java/com/google/jimfs/internal/JimfsAsynchronousFileChannel.java
+++ b/jimfs/src/main/java/com/google/jimfs/JimfsAsynchronousFileChannel.java
@@ -14,11 +14,10 @@
* limitations under the License.
*/
-package com.google.jimfs.internal;
+package com.google.jimfs;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.jimfs.internal.Util.checkNotNegative;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
@@ -83,8 +82,8 @@ final class JimfsAsynchronousFileChannel extends AsynchronousFileChannel {
@Override
public ListenableFuture<FileLock> lock(
final long position, final long size, final boolean shared) {
- checkNotNegative(position, "position");
- checkNotNegative(size, "size");
+ Util.checkNotNegative(position, "position");
+ Util.checkNotNegative(size, "size");
if (!isOpen()) {
return closedChannelFuture();
}
@@ -103,8 +102,8 @@ final class JimfsAsynchronousFileChannel extends AsynchronousFileChannel {
@Override
public FileLock tryLock(long position, long size, boolean shared) throws IOException {
- checkNotNegative(position, "position");
- checkNotNegative(size, "size");
+ Util.checkNotNegative(position, "position");
+ Util.checkNotNegative(size, "size");
channel.checkOpen();
if (shared) {
channel.checkReadable();
@@ -123,7 +122,7 @@ final class JimfsAsynchronousFileChannel extends AsynchronousFileChannel {
@Override
public ListenableFuture<Integer> read(final ByteBuffer dst, final long position) {
checkArgument(!dst.isReadOnly(), "dst may not be read-only");
- checkNotNegative(position, "position");
+ Util.checkNotNegative(position, "position");
if (!isOpen()) {
return closedChannelFuture();
}
@@ -144,7 +143,7 @@ final class JimfsAsynchronousFileChannel extends AsynchronousFileChannel {
@Override
public ListenableFuture<Integer> write(final ByteBuffer src, final long position) {
- checkNotNegative(position, "position");
+ Util.checkNotNegative(position, "position");
if (!isOpen()) {
return closedChannelFuture();
}
diff --git a/jimfs/src/main/java/com/google/jimfs/internal/JimfsDirectoryStream.java b/jimfs/src/main/java/com/google/jimfs/JimfsDirectoryStream.java
index d53b0f0..2801d3b 100644
--- a/jimfs/src/main/java/com/google/jimfs/internal/JimfsDirectoryStream.java
+++ b/jimfs/src/main/java/com/google/jimfs/JimfsDirectoryStream.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.internal;
+package com.google.jimfs;
import static com.google.common.base.Preconditions.checkNotNull;
diff --git a/jimfs/src/main/java/com/google/jimfs/internal/JimfsFileChannel.java b/jimfs/src/main/java/com/google/jimfs/JimfsFileChannel.java
index 23c7953..a29a06b 100644
--- a/jimfs/src/main/java/com/google/jimfs/internal/JimfsFileChannel.java
+++ b/jimfs/src/main/java/com/google/jimfs/JimfsFileChannel.java
@@ -14,12 +14,10 @@
* limitations under the License.
*/
-package com.google.jimfs.internal;
+package com.google.jimfs;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkPositionIndexes;
-import static com.google.jimfs.internal.Util.checkNoneNull;
-import static com.google.jimfs.internal.Util.checkNotNegative;
import static java.nio.file.StandardOpenOption.APPEND;
import static java.nio.file.StandardOpenOption.READ;
import static java.nio.file.StandardOpenOption.WRITE;
@@ -167,7 +165,7 @@ final class JimfsFileChannel extends FileChannel {
public long read(ByteBuffer[] dsts, int offset, int length) throws IOException {
checkPositionIndexes(offset, offset + length, dsts.length);
List<ByteBuffer> buffers = Arrays.asList(dsts).subList(offset, offset + length);
- checkNoneNull(buffers);
+ Util.checkNoneNull(buffers);
checkOpen();
checkReadable();
@@ -246,7 +244,7 @@ final class JimfsFileChannel extends FileChannel {
public long write(ByteBuffer[] srcs, int offset, int length) throws IOException {
checkPositionIndexes(offset, offset + length, srcs.length);
List<ByteBuffer> buffers = Arrays.asList(srcs).subList(offset, offset + length);
- checkNoneNull(buffers);
+ Util.checkNoneNull(buffers);
checkOpen();
checkWritable();
@@ -294,7 +292,7 @@ final class JimfsFileChannel extends FileChannel {
@Override
public FileChannel position(long newPosition) throws IOException {
- checkNotNegative(newPosition, "newPosition");
+ Util.checkNotNegative(newPosition, "newPosition");
checkOpen();
synchronized (this) {
@@ -312,7 +310,7 @@ final class JimfsFileChannel extends FileChannel {
@Override
public FileChannel truncate(long size) throws IOException {
- checkNotNegative(size, "size");
+ Util.checkNotNegative(size, "size");
checkOpen();
checkWritable();
@@ -357,8 +355,8 @@ final class JimfsFileChannel extends FileChannel {
@Override
public long transferTo(long position, long count, WritableByteChannel target) throws IOException {
checkNotNull(target);
- checkNotNegative(position, "position");
- checkNotNegative(count, "count");
+ Util.checkNotNegative(position, "position");
+ Util.checkNotNegative(count, "count");
checkOpen();
checkReadable();
@@ -393,8 +391,8 @@ final class JimfsFileChannel extends FileChannel {
@Override
public long transferFrom(ReadableByteChannel src, long position, long count) throws IOException {
checkNotNull(src);
- checkNotNegative(position, "position");
- checkNotNegative(count, "count");
+ Util.checkNotNegative(position, "position");
+ Util.checkNotNegative(count, "count");
checkOpen();
checkWritable();
@@ -438,7 +436,7 @@ final class JimfsFileChannel extends FileChannel {
@Override
public int read(ByteBuffer dst, long position) throws IOException {
checkNotNull(dst);
- checkNotNegative(position, "position");
+ Util.checkNotNegative(position, "position");
checkOpen();
checkReadable();
@@ -473,7 +471,7 @@ final class JimfsFileChannel extends FileChannel {
@Override
public int write(ByteBuffer src, long position) throws IOException {
checkNotNull(src);
- checkNotNegative(position, "position");
+ Util.checkNotNegative(position, "position");
checkOpen();
checkWritable();
@@ -523,8 +521,8 @@ final class JimfsFileChannel extends FileChannel {
@Override
public FileLock lock(long position, long size, boolean shared) throws IOException {
- checkNotNegative(position, "position");
- checkNotNegative(size, "size");
+ Util.checkNotNegative(position, "position");
+ Util.checkNotNegative(size, "size");
checkOpen();
if (shared) {
checkReadable();
diff --git a/jimfs/src/main/java/com/google/jimfs/internal/JimfsFileStore.java b/jimfs/src/main/java/com/google/jimfs/JimfsFileStore.java
index 8ba8800..7d4b514 100644
--- a/jimfs/src/main/java/com/google/jimfs/internal/JimfsFileStore.java
+++ b/jimfs/src/main/java/com/google/jimfs/JimfsFileStore.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.internal;
+package com.google.jimfs;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -22,7 +22,6 @@ import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedSet;
-import com.google.jimfs.attribute.Inode;
import java.io.IOException;
import java.nio.file.FileStore;
@@ -172,7 +171,7 @@ final class JimfsFileStore extends FileStore {
* {@code null} if the view type is not supported.
*/
@Nullable
- <V extends FileAttributeView> V getFileAttributeView(Inode.Lookup lookup, Class<V> type) {
+ <V extends FileAttributeView> V getFileAttributeView(FileLookup lookup, Class<V> type) {
return attributes.getFileAttributeView(lookup, type);
}
diff --git a/jimfs/src/main/java/com/google/jimfs/JimfsFileSystem.java b/jimfs/src/main/java/com/google/jimfs/JimfsFileSystem.java
new file mode 100644
index 0000000..bd9f6d9
--- /dev/null
+++ b/jimfs/src/main/java/com/google/jimfs/JimfsFileSystem.java
@@ -0,0 +1,357 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.jimfs;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSortedSet;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.net.URI;
+import java.nio.file.FileStore;
+import java.nio.file.FileSystem;
+import java.nio.file.Path;
+import java.nio.file.PathMatcher;
+import java.nio.file.WatchService;
+import java.nio.file.attribute.UserPrincipalLookupService;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import javax.annotation.Nullable;
+
+/**
+ * {@link FileSystem} implementation for JimFS. Most behavior for the file system is implemented
+ * by its {@linkplain #getDefaultView() default file system view}.
+ *
+ * <h3>Overview of file system design</h3>
+ *
+ * {@link com.google.jimfs.JimfsFileSystem JimfsFileSystem} instances are created by
+ * {@link com.google.jimfs.JimfsFileSystems JimfsFileSystems} using a user-provided
+ * {@link com.google.jimfs.Configuration Configuration}. The configuration is used to create the
+ * various classes that implement the file system with the correct settings and to create the file
+ * system root directories and working directory. The file system is then used to create the
+ * {@code Path} objects that all file system operations use.
+ *
+ * <p>Once created, the primary entry points to the file system are
+ * {@link com.google.jimfs.JimfsFileSystemProvider JimfsFileSystemProvider}, which handles
+ * calls to methods in {@link java.nio.file.Files}, and
+ * {@link com.google.jimfs.JimfsSecureDirectoryStream JimfsSecureDirectoryStream}, which
+ * provides methods that are similar to those of the file system provider but which treat relative
+ * paths as relative to the stream's directory rather than the file system's working directory.
+ *
+ * <p>The implementation of the methods on both of those classes is handled by the
+ * {@link com.google.jimfs.FileSystemView FileSystemView} class, which acts as a view of
+ * the file system with a specific working directory. The file system provider uses the file
+ * system's default view, while each secure directory stream uses a view specific to that stream.
+ *
+ * <p>File system views make use of the file system's singleton
+ * {@link com.google.jimfs.JimfsFileStore JimfsFileStore} which handles file creation,
+ * storage and attributes. The file store delegates to several other classes to handle each of
+ * these:
+ *
+ * <ul>
+ * <li>{@link com.google.jimfs.FileFactory FileFactory} handles creation of new file
+ * objects.</li>
+ * <li>{@link com.google.jimfs.HeapDisk HeapDisk} handles creation and storage of
+ * {@link com.google.jimfs.ByteStore ByteStore} instances, which act as the content of
+ * regular files.</li>
+ * <li>{@link com.google.jimfs.FileTree FileTree} stores the root of the file hierarchy
+ * and handles file lookup.</li>
+ * <li>{@link com.google.jimfs.AttributeService AttributeService} handles file
+ * attributes, using a set of
+ * {@link com.google.jimfs.AttributeProvider AttributeProvider} implementations to
+ * handle each supported file attribute view.</li>
+ * </ul>
+ *
+ * <h3>Paths</h3>
+ *
+ * The implementation of {@link java.nio.file.Path} for the file system is
+ * {@link com.google.jimfs.JimfsPath JimfsPath}. Paths are created by a
+ * {@link com.google.jimfs.PathService PathService} with help from the file system's
+ * configured {@link com.google.jimfs.PathType PathType}.
+ *
+ * <p>Paths are made up of {@link com.google.jimfs.Name Name} objects, which also serve as
+ * the file names in directories. A name has two forms:
+ *
+ * <ul>
+ * <li>The <b>display form</b> is used in {@code Path} for {@code toString()}. It is also used for
+ * determining the equality and sort order of {@code Path} objects for most file systems.</li>
+ * <li>The <b>canonical form</b> is used for equality of two {@code Name} objects. This affects
+ * the notion of name equality in the file system itself for file lookup. A file system may be
+ * configured to use the canonical form of the name for path equality (a Windows-like file system
+ * configuration does this, as the real Windows file system implementation uses case-insensitive
+ * equality for its path objects.</li>
+ * </ul>
+ *
+ * <p>The canonical form of a name is created by applying a series of
+ * {@linkplain PathNormalization normalizations} to the original string. These
+ * normalization may be either a Unicode normalization (e.g. NFD) or case folding normalization for
+ * case-insensitivity. Normalizations may also be applied to the display form of a name, but this
+ * is currently only done for a Mac OS X type configuration.
+ *
+ * <h3>Files</h3>
+ *
+ * All files in the file system are an instance of {@link com.google.jimfs.File File}. A
+ * file object contains the file's attributes as well as a reference to the file's
+ * {@linkplain com.google.jimfs.FileContent content}.
+ *
+ * <p>There are three types of file content:
+ *
+ * <ul>
+ * <li>{@link com.google.jimfs.DirectoryTable DirectoryTable} - a map linking file names
+ * to {@linkplain com.google.jimfs.DirectoryEntry directory entries}. A file with a
+ * directory table as its content is, obviously, a <i>directory</i>.</li>
+ * <li>{@link com.google.jimfs.ByteStore ByteStore} - an in-memory store for raw bytes.
+ * A file with a byte store as its content is a <i>regular file</i>.</li>
+ * <li>{@link com.google.jimfs.JimfsPath JimfsPath} - A file with a path as its content
+ * is a <i>symbolic link</i>.</li>
+ * </ul>
+ *
+ * <p>{@link com.google.jimfs.JimfsFileChannel JimfsFileChannel},
+ * {@link com.google.jimfs.JimfsInputStream JimfsInputStream} and
+ * {@link com.google.jimfs.JimfsOutputStream JimfsOutputStream} implement the standard
+ * channel/stream APIs for regular files.
+ *
+ * <p>{@link com.google.jimfs.JimfsDirectoryStream JimfsDirectoryStream} and
+ * {@link com.google.jimfs.JimfsSecureDirectoryStream JimfsSecureDirectoryStream} handle
+ * reading the entries of a directory. The secure directory stream additionally contains a
+ * {@code FileSystemView} with its directory as the working directory, allowing for operations
+ * relative to the actual directory file rather than just the path to the file. This allows the
+ * operations to continue to work as expected even if the directory is moved.
+ *
+ * <p>A directory can be watched for changes using the {@link java.nio.file.WatchService}
+ * implementation, {@link com.google.jimfs.PollingWatchService PollingWatchService}.
+ *
+ * <h3>Regular files</h3>
+ *
+ * Currently, the only implementation for regular file content is
+ * {@link com.google.jimfs.ByteStore ByteStore}, which makes use of a singleton
+ * {@link com.google.jimfs.HeapDisk HeapDisk}. A disk is a resizable factory and cache for
+ * fixed size blocks of memory. These blocks are allocated to files as needed and returned to the
+ * disk when a file is deleted or truncated. When cached free blocks are available, those blocks
+ * are allocated to files first. If more blocks are needed, they are created.
+ *
+ * <h3>Linking</h3>
+ *
+ * When a file is mapped to a file name in a directory table, it is <i>linked</i>. Each type of
+ * file has different rules governing how it is linked.
+ *
+ * <ul>
+ * <li>Directory - A directory has two or more links to it. The first is the link from
+ * its parent directory to it. This link is the name of the directory. The second is the
+ * <i>self</i> link (".") which links the directory to itself. The directory may also have any
+ * number of additional <i>parent</i> links ("..") from child directories back to it.</li>
+ * <li>Regular file - A regular file has one link from its parent directory by default. However,
+ * regular files are also allowed to have any number of additional user-created hard links, from
+ * the same directory with different names and/or from other directories with any names.</li>
+ * <li>Symbolic link - A symbolic link can only have one link, from its parent directory.</li>
+ * </ul>
+ *
+ * <h3>Thread safety</h3>
+ *
+ * All file system operations should be safe in a multithreaded environment. The file hierarchy
+ * itself is protected by a file system level read-write lock. This ensures safety of all
+ * modifications to directory tables as well as atomicity of operations like file moves. Regular
+ * files are each protected by a read-write lock on their content which is obtained for each read
+ * or write operation. File attributes are not protected by locks, but are stored in thread-safe
+ * concurrent maps and atomic numbers.
+ *
+ * @author Colin Decker
+ */
+final class JimfsFileSystem extends FileSystem {
+
+ private final JimfsFileSystemProvider provider;
+ private final URI uri;
+
+ private final JimfsFileStore fileStore;
+ private final PathService pathService;
+
+ private final ResourceManager resourceManager = new ResourceManager();
+ private final UserPrincipalLookupService userLookupService = new UserLookupService(true);
+
+ private final FileSystemView defaultView;
+
+ JimfsFileSystem(JimfsFileSystemProvider provider, URI uri, JimfsFileStore fileStore,
+ PathService pathService, FileSystemView defaultView) {
+ this.provider = checkNotNull(provider);
+ this.uri = checkNotNull(uri);
+ this.fileStore = checkNotNull(fileStore);
+ this.pathService = checkNotNull(pathService);
+ this.defaultView = checkNotNull(defaultView);
+ }
+
+ @Override
+ public JimfsFileSystemProvider provider() {
+ return provider;
+ }
+
+ /**
+ * Returns the URI for this file system.
+ */
+ public URI getUri() {
+ return uri;
+ }
+
+ /**
+ * Returns the default view for this file system.
+ */
+ public FileSystemView getDefaultView() {
+ return defaultView;
+ }
+
+ @Override
+ public String getSeparator() {
+ return pathService.getSeparator();
+ }
+
+ @SuppressWarnings("unchecked") // safe cast of immutable set
+ @Override
+ public ImmutableSortedSet<Path> getRootDirectories() {
+ ImmutableSortedSet.Builder<JimfsPath> builder = ImmutableSortedSet.orderedBy(pathService);
+ for (Name name : fileStore.getRootDirectoryNames()) {
+ builder.add(pathService.createRoot(name));
+ }
+ return (ImmutableSortedSet<Path>) (ImmutableSortedSet<?>) builder.build();
+ }
+
+ /**
+ * Returns the working directory path for this file system.
+ */
+ public JimfsPath getWorkingDirectory() {
+ return defaultView.getWorkingDirectoryPath();
+ }
+
+ /**
+ * Returns the path service for this file system.
+ */
+ @VisibleForTesting
+ PathService getPathService() {
+ return pathService;
+ }
+
+ /**
+ * Returns the file store for this file system.
+ */
+ public JimfsFileStore getFileStore() {
+ return fileStore;
+ }
+
+ @Override
+ public ImmutableSet<FileStore> getFileStores() {
+ return ImmutableSet.<FileStore>of(fileStore);
+ }
+
+ @Override
+ public ImmutableSet<String> supportedFileAttributeViews() {
+ return fileStore.supportedFileAttributeViews();
+ }
+
+ @Override
+ public JimfsPath getPath(String first, String... more) {
+ return pathService.parsePath(first, more);
+ }
+
+ /**
+ * Gets the URI of the given path in this file system.
+ */
+ public URI toUri(JimfsPath path) {
+ return pathService.toUri(uri, path.toAbsolutePath());
+ }
+
+ /**
+ * Converts the given URI into a path in this file system.
+ */
+ public JimfsPath toPath(URI uri) {
+ return pathService.fromUri(uri);
+ }
+
+ @Override
+ public PathMatcher getPathMatcher(String syntaxAndPattern) {
+ return pathService.createPathMatcher(syntaxAndPattern);
+ }
+
+ @Override
+ public UserPrincipalLookupService getUserPrincipalLookupService() {
+ return userLookupService;
+ }
+
+ @Override
+ public synchronized WatchService newWatchService() throws IOException {
+ // synchronized for resourceManager to register the watch service so there are no races between
+ // creating a watch service and closing the file system
+ return new PollingWatchService(defaultView, pathService, resourceManager);
+ }
+
+ @Nullable
+ private ExecutorService defaultThreadPool;
+
+ /**
+ * Returns a default thread pool to use for asynchronous file channels when users do not provide
+ * an executor themselves. (This is required by the spec of newAsynchronousFileChannel in
+ * FileSystemProvider.)
+ */
+ public synchronized ExecutorService getDefaultThreadPool() {
+ if (defaultThreadPool == null) {
+ defaultThreadPool = Executors.newCachedThreadPool(new ThreadFactoryBuilder()
+ .setDaemon(true)
+ .setNameFormat("JimfsFileSystem-" + uri.getHost() + "-defaultThreadPool-%s")
+ .build());
+
+ // ensure thread pool is closed when file system is closed
+ resourceManager.register(new Closeable() {
+ @Override
+ public void close() {
+ defaultThreadPool.shutdown();
+ }
+ });
+ }
+ return defaultThreadPool;
+ }
+
+ /**
+ * Returns {@code false}; currently, cannot create a read-only file system.
+ *
+ * @return {@code false}, always
+ */
+ @Override
+ public boolean isReadOnly() {
+ return false;
+ }
+
+ private boolean open = true;
+
+ @Override
+ public synchronized boolean isOpen() {
+ return open;
+ }
+
+ @Override
+ public synchronized void close() throws IOException {
+ if (open) {
+ open = false;
+ try {
+ resourceManager.close();
+ } finally {
+ provider.remove(this);
+ }
+ }
+ }
+}
diff --git a/jimfs/src/main/java/com/google/jimfs/internal/JimfsFileSystemProvider.java b/jimfs/src/main/java/com/google/jimfs/JimfsFileSystemProvider.java
index aaeca2e..3ed75ea 100644
--- a/jimfs/src/main/java/com/google/jimfs/internal/JimfsFileSystemProvider.java
+++ b/jimfs/src/main/java/com/google/jimfs/JimfsFileSystemProvider.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.internal;
+package com.google.jimfs;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -24,8 +24,6 @@ import static com.google.jimfs.Jimfs.URI_SCHEME;
import static java.nio.file.StandardOpenOption.APPEND;
import com.google.common.collect.ImmutableSet;
-import com.google.jimfs.Configuration;
-import com.google.jimfs.Jimfs;
import java.io.IOException;
import java.io.InputStream;
@@ -59,9 +57,9 @@ import java.util.concurrent.ExecutorService;
import javax.annotation.Nullable;
/**
- * {@link FileSystemProvider} implementation for JimFS. Should not be used directly. To create a
- * new file system instance, see {@link Jimfs}. For other operations, use the public APIs in
- * {@code java.nio.file}.
+ * {@link FileSystemProvider} implementation for JimFS. While this class is public, it should not
+ * be used directly. To create a new file system instance, see {@link Jimfs}. For other operations,
+ * use the public APIs in {@code java.nio.file}.
*
* @author Colin Decker
*/
diff --git a/jimfs/src/main/java/com/google/jimfs/internal/JimfsFileSystems.java b/jimfs/src/main/java/com/google/jimfs/JimfsFileSystems.java
index 5bfece6..60dc434 100644
--- a/jimfs/src/main/java/com/google/jimfs/internal/JimfsFileSystems.java
+++ b/jimfs/src/main/java/com/google/jimfs/JimfsFileSystems.java
@@ -14,9 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.internal;
-
-import com.google.jimfs.Configuration;
+package com.google.jimfs;
import java.io.IOException;
import java.net.URI;
@@ -64,7 +62,7 @@ final class JimfsFileSystems {
Map<Name, File> roots = new HashMap<>();
// create roots
- for (String root : config.roots()) {
+ for (String root : config.roots) {
JimfsPath path = pathService.parsePath(root);
if (!path.isAbsolute() && path.getNameCount() == 0) {
throw new IllegalArgumentException("Invalid root path: " + root);
@@ -86,7 +84,7 @@ final class JimfsFileSystems {
*/
private static FileSystemView createDefaultView(Configuration config,
JimfsFileStore fileStore, PathService pathService) throws IOException {
- JimfsPath workingDirPath = pathService.parsePath(config.workingDirectory());
+ JimfsPath workingDirPath = pathService.parsePath(config.workingDirectory);
File dir = fileStore.getRoot(workingDirPath.root());
if (dir == null) {
diff --git a/jimfs/src/main/java/com/google/jimfs/internal/JimfsInputStream.java b/jimfs/src/main/java/com/google/jimfs/JimfsInputStream.java
index 77ee512..ea77734 100644
--- a/jimfs/src/main/java/com/google/jimfs/internal/JimfsInputStream.java
+++ b/jimfs/src/main/java/com/google/jimfs/JimfsInputStream.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.internal;
+package com.google.jimfs;
import static com.google.common.base.Preconditions.checkPositionIndexes;
diff --git a/jimfs/src/main/java/com/google/jimfs/internal/JimfsOutputStream.java b/jimfs/src/main/java/com/google/jimfs/JimfsOutputStream.java
index 38f6d5e..942fe51 100644
--- a/jimfs/src/main/java/com/google/jimfs/internal/JimfsOutputStream.java
+++ b/jimfs/src/main/java/com/google/jimfs/JimfsOutputStream.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.internal;
+package com.google.jimfs;
import static com.google.common.base.Preconditions.checkPositionIndexes;
diff --git a/jimfs/src/main/java/com/google/jimfs/internal/JimfsPath.java b/jimfs/src/main/java/com/google/jimfs/JimfsPath.java
index ea85355..1f419a2 100644
--- a/jimfs/src/main/java/com/google/jimfs/internal/JimfsPath.java
+++ b/jimfs/src/main/java/com/google/jimfs/JimfsPath.java
@@ -14,12 +14,10 @@
* limitations under the License.
*/
-package com.google.jimfs.internal;
+package com.google.jimfs;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.jimfs.internal.Name.PARENT;
-import static com.google.jimfs.internal.Name.SELF;
import com.google.common.base.Objects;
import com.google.common.collect.ComparisonChain;
@@ -233,15 +231,15 @@ final class JimfsPath implements Path, FileContent {
Deque<Name> newNames = new ArrayDeque<>();
for (Name name : names) {
- if (name.equals(PARENT)) {
+ if (name.equals(Name.PARENT)) {
Name lastName = newNames.peekLast();
- if (lastName != null && !lastName.equals(PARENT)) {
+ if (lastName != null && !lastName.equals(Name.PARENT)) {
newNames.removeLast();
} else if (!isAbsolute()) {
// if there's a root and we have an extra ".." that would go up above the root, ignore it
newNames.add(name);
}
- } else if (!name.equals(SELF)) {
+ } else if (!name.equals(Name.SELF)) {
newNames.add(name);
}
}
@@ -261,13 +259,13 @@ final class JimfsPath implements Path, FileContent {
boolean foundNonParentName = isAbsolute(); // if there's a root, the path doesn't start with ..
boolean normal = true;
for (Name name : names) {
- if (name.equals(PARENT)) {
+ if (name.equals(Name.PARENT)) {
if (foundNonParentName) {
normal = false;
break;
}
} else {
- if (name.equals(SELF)) {
+ if (name.equals(Name.SELF)) {
normal = false;
break;
}
@@ -374,7 +372,7 @@ final class JimfsPath implements Path, FileContent {
List<Name> parts = new ArrayList<>(extraNamesInThis + extraNamesInOther.size());
// add .. for each extra name in this path
- Iterables.addAll(parts, Collections.nCopies(extraNamesInThis, PARENT));
+ Iterables.addAll(parts, Collections.nCopies(extraNamesInThis, Name.PARENT));
// add each extra name in the other path
Iterables.addAll(parts, extraNamesInOther);
diff --git a/jimfs/src/main/java/com/google/jimfs/internal/JimfsSecureDirectoryStream.java b/jimfs/src/main/java/com/google/jimfs/JimfsSecureDirectoryStream.java
index 2ac7e77..68d7c52 100644
--- a/jimfs/src/main/java/com/google/jimfs/internal/JimfsSecureDirectoryStream.java
+++ b/jimfs/src/main/java/com/google/jimfs/JimfsSecureDirectoryStream.java
@@ -14,9 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.internal;
-
-import static com.google.jimfs.internal.FileSystemView.DeleteMode;
+package com.google.jimfs;
import com.google.common.collect.ImmutableSet;
@@ -73,13 +71,13 @@ final class JimfsSecureDirectoryStream
@Override
public void deleteFile(Path path) throws IOException {
JimfsPath checkedPath = checkPath(path);
- view.deleteFile(checkedPath, DeleteMode.NON_DIRECTORY_ONLY);
+ view.deleteFile(checkedPath, FileSystemView.DeleteMode.NON_DIRECTORY_ONLY);
}
@Override
public void deleteDirectory(Path path) throws IOException {
JimfsPath checkedPath = checkPath(path);
- view.deleteFile(checkedPath, DeleteMode.DIRECTORY_ONLY);
+ view.deleteFile(checkedPath, FileSystemView.DeleteMode.DIRECTORY_ONLY);
}
@Override
diff --git a/jimfs/src/main/java/com/google/jimfs/internal/Name.java b/jimfs/src/main/java/com/google/jimfs/Name.java
index f3c9cbb..a4162e6 100644
--- a/jimfs/src/main/java/com/google/jimfs/internal/Name.java
+++ b/jimfs/src/main/java/com/google/jimfs/Name.java
@@ -14,10 +14,9 @@
* limitations under the License.
*/
-package com.google.jimfs.internal;
+package com.google.jimfs;
import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.jimfs.internal.Util.smearHash;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
@@ -91,7 +90,7 @@ final class Name {
@Override
public int hashCode() {
- return smearHash(canonical.hashCode());
+ return Util.smearHash(canonical.hashCode());
}
@Override
diff --git a/jimfs/src/main/java/com/google/jimfs/internal/Options.java b/jimfs/src/main/java/com/google/jimfs/Options.java
index dc689f1..9af5821 100644
--- a/jimfs/src/main/java/com/google/jimfs/internal/Options.java
+++ b/jimfs/src/main/java/com/google/jimfs/Options.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.internal;
+package com.google.jimfs;
import static com.google.common.base.Preconditions.checkNotNull;
import static java.nio.file.StandardCopyOption.ATOMIC_MOVE;
diff --git a/jimfs/src/main/java/com/google/jimfs/attribute/OwnerAttributeProvider.java b/jimfs/src/main/java/com/google/jimfs/OwnerAttributeProvider.java
index 4773a38..96de573 100644
--- a/jimfs/src/main/java/com/google/jimfs/attribute/OwnerAttributeProvider.java
+++ b/jimfs/src/main/java/com/google/jimfs/OwnerAttributeProvider.java
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-package com.google.jimfs.attribute;
+package com.google.jimfs;
import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.jimfs.attribute.UserPrincipals.createUserPrincipal;
+import static com.google.jimfs.UserPrincipals.createUserPrincipal;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
@@ -71,22 +71,22 @@ final class OwnerAttributeProvider extends AttributeProvider {
@Nullable
@Override
- public Object get(Inode inode, String attribute) {
+ public Object get(File file, String attribute) {
if (attribute.equals("owner")) {
- return inode.getAttribute("owner", "owner");
+ return file.getAttribute("owner", "owner");
}
return null;
}
@Override
- public void set(Inode inode, String view, String attribute, Object value,
+ public void set(File file, String view, String attribute, Object value,
boolean create) {
if (attribute.equals("owner")) {
UserPrincipal user = checkType(view, attribute, value, UserPrincipal.class);
if (!(user instanceof UserPrincipals.JimfsUserPrincipal)) {
user = createUserPrincipal(user.getName());
}
- inode.setAttribute("owner", "owner", user);
+ file.setAttribute("owner", "owner", user);
}
}
@@ -96,7 +96,7 @@ final class OwnerAttributeProvider extends AttributeProvider {
}
@Override
- public FileOwnerAttributeView view(Inode.Lookup lookup,
+ public FileOwnerAttributeView view(FileLookup lookup,
ImmutableMap<String, FileAttributeView> inheritedViews) {
return new View(lookup);
}
@@ -106,7 +106,7 @@ final class OwnerAttributeProvider extends AttributeProvider {
*/
private static final class View extends AbstractAttributeView implements FileOwnerAttributeView {
- public View(Inode.Lookup lookup) {
+ public View(FileLookup lookup) {
super(lookup);
}
@@ -117,12 +117,12 @@ final class OwnerAttributeProvider extends AttributeProvider {
@Override
public UserPrincipal getOwner() throws IOException {
- return (UserPrincipal) lookupInode().getAttribute("owner", "owner");
+ return (UserPrincipal) lookupFile().getAttribute("owner", "owner");
}
@Override
public void setOwner(UserPrincipal owner) throws IOException {
- lookupInode().setAttribute("owner", "owner", checkNotNull(owner));
+ lookupFile().setAttribute("owner", "owner", checkNotNull(owner));
}
}
}
diff --git a/jimfs/src/main/java/com/google/jimfs/internal/PathMatchers.java b/jimfs/src/main/java/com/google/jimfs/PathMatchers.java
index 6e104c2..db090e4 100644
--- a/jimfs/src/main/java/com/google/jimfs/internal/PathMatchers.java
+++ b/jimfs/src/main/java/com/google/jimfs/PathMatchers.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.internal;
+package com.google.jimfs;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -23,7 +23,6 @@ import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Ascii;
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableSet;
-import com.google.jimfs.path.Normalization;
import java.nio.file.FileSystem;
import java.nio.file.Path;
@@ -49,7 +48,7 @@ final class PathMatchers {
// TODO(cgdecker): Should I be just canonicalizing separators rather than matching any separator?
// Perhaps so, assuming Path always canonicalizes its separators
public static PathMatcher getPathMatcher(
- String syntaxAndPattern, String separators, ImmutableSet<Normalization> normalizations) {
+ String syntaxAndPattern, String separators, ImmutableSet<PathNormalization> normalizations) {
int syntaxSeparator = syntaxAndPattern.indexOf(':');
checkArgument(syntaxSeparator > 0, "Must be of the form 'syntax:pattern': %s",
syntaxAndPattern);
@@ -68,8 +67,8 @@ final class PathMatchers {
}
}
- private static PathMatcher fromRegex(String regex, Iterable<Normalization> normalizations) {
- return new RegexPathMatcher(Normalization.compilePattern(regex, normalizations));
+ private static PathMatcher fromRegex(String regex, Iterable<PathNormalization> normalizations) {
+ return new RegexPathMatcher(PathNormalization.compilePattern(regex, normalizations));
}
/**
diff --git a/jimfs/src/main/java/com/google/jimfs/path/Normalization.java b/jimfs/src/main/java/com/google/jimfs/PathNormalization.java
index 810a2fc..342b669 100644
--- a/jimfs/src/main/java/com/google/jimfs/path/Normalization.java
+++ b/jimfs/src/main/java/com/google/jimfs/PathNormalization.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.path;
+package com.google.jimfs;
import com.google.common.base.Ascii;
import com.google.common.base.Function;
@@ -32,7 +32,7 @@ import java.util.regex.Pattern;
*
* @author Colin Decker
*/
-public enum Normalization implements Function<String, String> {
+public enum PathNormalization implements Function<String, String> {
/**
* No normalization.
@@ -75,8 +75,9 @@ public enum Normalization implements Function<String, String> {
try {
return UCharacter.foldCase(string, true);
} catch (NoClassDefFoundError e) {
- NoClassDefFoundError error = new NoClassDefFoundError("Normalization.CASE_FOLD_UNICODE "
- + "requires ICU4J. Did you forget to include it on your classpath?");
+ NoClassDefFoundError error = new NoClassDefFoundError(
+ "PathNormalization.CASE_FOLD_UNICODE requires ICU4J. " +
+ "Did you forget to include it on your classpath?");
error.initCause(e);
throw error;
}
@@ -95,7 +96,7 @@ public enum Normalization implements Function<String, String> {
private final int patternFlags;
- private Normalization(int patternFlags) {
+ private PathNormalization(int patternFlags) {
this.patternFlags = patternFlags;
}
@@ -117,9 +118,9 @@ public enum Normalization implements Function<String, String> {
* Applies the given normalizations to the given string in order, returning the normalized
* result.
*/
- public static String normalize(String string, Iterable<Normalization> normalizations) {
+ public static String normalize(String string, Iterable<PathNormalization> normalizations) {
String result = string;
- for (Normalization normalization : normalizations) {
+ for (PathNormalization normalization : normalizations) {
result = normalization.apply(result);
}
return result;
@@ -128,9 +129,9 @@ public enum Normalization implements Function<String, String> {
/**
* Compiles a regex pattern using flags based on the given normalizations.
*/
- public static Pattern compilePattern(String regex, Iterable<Normalization> normalizations) {
+ public static Pattern compilePattern(String regex, Iterable<PathNormalization> normalizations) {
int flags = 0;
- for (Normalization normalization : normalizations) {
+ for (PathNormalization normalization : normalizations) {
flags |= normalization.patternFlags();
}
return Pattern.compile(regex, flags);
diff --git a/jimfs/src/main/java/com/google/jimfs/internal/PathService.java b/jimfs/src/main/java/com/google/jimfs/PathService.java
index ee01c4b..5ba6391 100644
--- a/jimfs/src/main/java/com/google/jimfs/internal/PathService.java
+++ b/jimfs/src/main/java/com/google/jimfs/PathService.java
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-package com.google.jimfs.internal;
+package com.google.jimfs;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
-import static com.google.jimfs.path.PathType.ParseResult;
+import static com.google.jimfs.PathType.ParseResult;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Functions;
@@ -30,9 +30,6 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Ordering;
-import com.google.jimfs.Configuration;
-import com.google.jimfs.path.Normalization;
-import com.google.jimfs.path.PathType;
import java.net.URI;
import java.nio.file.FileSystem;
@@ -62,8 +59,8 @@ final class PathService implements Comparator<JimfsPath> {
private final PathType type;
- private final ImmutableSet<Normalization> displayNormalizations;
- private final ImmutableSet<Normalization> canonicalNormalizations;
+ private final ImmutableSet<PathNormalization> displayNormalizations;
+ private final ImmutableSet<PathNormalization> canonicalNormalizations;
private final boolean equalityUsesCanonicalForm;
private final Ordering<Name> rootOrdering;
@@ -73,15 +70,15 @@ final class PathService implements Comparator<JimfsPath> {
private volatile JimfsPath emptyPath;
PathService(Configuration config) {
- this(config.pathType(),
- config.nameDisplayNormalization(),
- config.nameCanonicalNormalization(),
- config.pathEqualityUsesCanonicalForm());
+ this(config.pathType,
+ config.nameDisplayNormalization,
+ config.nameCanonicalNormalization,
+ config.pathEqualityUsesCanonicalForm);
}
PathService(PathType type,
- Iterable<Normalization> displayNormalizations,
- Iterable<Normalization> canonicalNormalizations,
+ Iterable<PathNormalization> displayNormalizations,
+ Iterable<PathNormalization> canonicalNormalizations,
boolean equalityUsesCanonicalForm) {
this.type = checkNotNull(type);
this.displayNormalizations = ImmutableSet.copyOf(displayNormalizations);
@@ -145,8 +142,8 @@ final class PathService implements Comparator<JimfsPath> {
case "..":
return Name.PARENT;
default:
- String display = Normalization.normalize(name, displayNormalizations);
- String canonical = Normalization.normalize(name, canonicalNormalizations);
+ String display = PathNormalization.normalize(name, displayNormalizations);
+ String canonical = PathNormalization.normalize(name, canonicalNormalizations);
return Name.create(display, canonical);
}
}
diff --git a/jimfs/src/main/java/com/google/jimfs/path/PathType.java b/jimfs/src/main/java/com/google/jimfs/PathType.java
index f70ccb8..0c57987 100644
--- a/jimfs/src/main/java/com/google/jimfs/path/PathType.java
+++ b/jimfs/src/main/java/com/google/jimfs/PathType.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.path;
+package com.google.jimfs;
import static com.google.common.base.Preconditions.checkNotNull;
diff --git a/jimfs/src/main/java/com/google/jimfs/internal/PollingWatchService.java b/jimfs/src/main/java/com/google/jimfs/PollingWatchService.java
index 4079781..2f990bb 100644
--- a/jimfs/src/main/java/com/google/jimfs/internal/PollingWatchService.java
+++ b/jimfs/src/main/java/com/google/jimfs/PollingWatchService.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.internal;
+package com.google.jimfs;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -58,7 +58,7 @@ final class PollingWatchService extends AbstractWatchService {
* running if the user doesn't close the watch service or the file system.
*/
private static final ThreadFactory THREAD_FACTORY = new ThreadFactoryBuilder()
- .setNameFormat("com.google.jimfs.internal.PollingWatchService-thread-%d")
+ .setNameFormat("com.google.jimfs.PollingWatchService-thread-%d")
.setDaemon(true)
.build();
diff --git a/jimfs/src/main/java/com/google/jimfs/attribute/PosixAttributeProvider.java b/jimfs/src/main/java/com/google/jimfs/PosixAttributeProvider.java
index 474ca08..099ef09 100644
--- a/jimfs/src/main/java/com/google/jimfs/attribute/PosixAttributeProvider.java
+++ b/jimfs/src/main/java/com/google/jimfs/PosixAttributeProvider.java
@@ -14,10 +14,9 @@
* limitations under the License.
*/
-package com.google.jimfs.attribute;
+package com.google.jimfs;
import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.jimfs.attribute.UserPrincipals.createGroupPrincipal;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
@@ -53,7 +52,7 @@ final class PosixAttributeProvider extends AttributeProvider {
private static final ImmutableSet<String> INHERITED_VIEWS = ImmutableSet.of("basic", "owner");
- private static final GroupPrincipal DEFAULT_GROUP = createGroupPrincipal("group");
+ private static final GroupPrincipal DEFAULT_GROUP = UserPrincipals.createGroupPrincipal("group");
private static final ImmutableSet<PosixFilePermission> DEFAULT_PERMISSIONS =
Sets.immutableEnumSet(PosixFilePermissions.fromString("rw-r--r--"));
@@ -80,9 +79,9 @@ final class PosixAttributeProvider extends AttributeProvider {
UserPrincipal group = DEFAULT_GROUP;
if (userProvidedGroup != null) {
if (userProvidedGroup instanceof String) {
- group = createGroupPrincipal((String) userProvidedGroup);
+ group = UserPrincipals.createGroupPrincipal((String) userProvidedGroup);
} else if (userProvidedGroup instanceof GroupPrincipal) {
- group = createGroupPrincipal(((GroupPrincipal) userProvidedGroup).getName());
+ group = UserPrincipals.createGroupPrincipal(((GroupPrincipal) userProvidedGroup).getName());
} else {
throw new IllegalArgumentException("invalid type " + userProvidedGroup.getClass()
+ " for attribute 'posix:group': should be one of " + String.class + " or "
@@ -113,19 +112,19 @@ final class PosixAttributeProvider extends AttributeProvider {
@Nullable
@Override
- public Object get(Inode inode, String attribute) {
+ public Object get(File file, String attribute) {
switch (attribute) {
case "group":
- return inode.getAttribute("posix", "group");
+ return file.getAttribute("posix", "group");
case "permissions":
- return inode.getAttribute("posix", "permissions");
+ return file.getAttribute("posix", "permissions");
default:
return null;
}
}
@Override
- public void set(Inode inode, String view, String attribute, Object value,
+ public void set(File file, String view, String attribute, Object value,
boolean create) {
switch (attribute) {
case "group":
@@ -135,10 +134,10 @@ final class PosixAttributeProvider extends AttributeProvider {
if (!(group instanceof UserPrincipals.JimfsGroupPrincipal)) {
group = UserPrincipals.createGroupPrincipal(group.getName());
}
- inode.setAttribute("posix", "group", group);
+ file.setAttribute("posix", "group", group);
break;
case "permissions":
- inode.setAttribute("posix", "permissions",
+ file.setAttribute("posix", "permissions",
toPermissions(checkType(view, attribute, value, Set.class)));
break;
default:
@@ -164,7 +163,7 @@ final class PosixAttributeProvider extends AttributeProvider {
}
@Override
- public PosixFileAttributeView view(Inode.Lookup lookup,
+ public PosixFileAttributeView view(FileLookup lookup,
ImmutableMap<String, FileAttributeView> inheritedViews) {
return new View(lookup,
(BasicFileAttributeView) inheritedViews.get("basic"),
@@ -177,8 +176,8 @@ final class PosixAttributeProvider extends AttributeProvider {
}
@Override
- public PosixFileAttributes readAttributes(Inode inode) {
- return new Attributes(inode);
+ public PosixFileAttributes readAttributes(File file) {
+ return new Attributes(file);
}
/**
@@ -189,7 +188,7 @@ final class PosixAttributeProvider extends AttributeProvider {
private final BasicFileAttributeView basicView;
private final FileOwnerAttributeView ownerView;
- protected View(Inode.Lookup lookup,
+ protected View(FileLookup lookup,
BasicFileAttributeView basicView, FileOwnerAttributeView ownerView) {
super(lookup);
this.basicView = checkNotNull(basicView);
@@ -203,7 +202,7 @@ final class PosixAttributeProvider extends AttributeProvider {
@Override
public PosixFileAttributes readAttributes() throws IOException {
- return new Attributes(lookupInode());
+ return new Attributes(lookupFile());
}
@Override
@@ -214,12 +213,12 @@ final class PosixAttributeProvider extends AttributeProvider {
@Override
public void setPermissions(Set<PosixFilePermission> perms) throws IOException {
- lookupInode().setAttribute("posix", "permissions", ImmutableSet.copyOf(perms));
+ lookupFile().setAttribute("posix", "permissions", ImmutableSet.copyOf(perms));
}
@Override
public void setGroup(GroupPrincipal group) throws IOException {
- lookupInode().setAttribute("posix", "group", checkNotNull(group));
+ lookupFile().setAttribute("posix", "group", checkNotNull(group));
}
@Override
@@ -243,12 +242,12 @@ final class PosixAttributeProvider extends AttributeProvider {
private final ImmutableSet<PosixFilePermission> permissions;
@SuppressWarnings("unchecked")
- protected Attributes(Inode inode) {
- super(inode);
- this.owner = (UserPrincipal) inode.getAttribute("owner", "owner");
- this.group = (GroupPrincipal) inode.getAttribute("posix", "group");
+ protected Attributes(File file) {
+ super(file);
+ this.owner = (UserPrincipal) file.getAttribute("owner", "owner");
+ this.group = (GroupPrincipal) file.getAttribute("posix", "group");
this.permissions =
- (ImmutableSet<PosixFilePermission>) inode.getAttribute("posix", "permissions");
+ (ImmutableSet<PosixFilePermission>) file.getAttribute("posix", "permissions");
}
@Override
diff --git a/jimfs/src/main/java/com/google/jimfs/internal/ResourceManager.java b/jimfs/src/main/java/com/google/jimfs/ResourceManager.java
index 60aa0c3..ea5f354 100644
--- a/jimfs/src/main/java/com/google/jimfs/internal/ResourceManager.java
+++ b/jimfs/src/main/java/com/google/jimfs/ResourceManager.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.internal;
+package com.google.jimfs;
import com.google.common.base.Throwables;
import com.google.common.collect.Sets;
diff --git a/jimfs/src/main/java/com/google/jimfs/attribute/StandardAttributeProviders.java b/jimfs/src/main/java/com/google/jimfs/StandardAttributeProviders.java
index fa39473..a0730cb 100644
--- a/jimfs/src/main/java/com/google/jimfs/attribute/StandardAttributeProviders.java
+++ b/jimfs/src/main/java/com/google/jimfs/StandardAttributeProviders.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.attribute;
+package com.google.jimfs;
import com.google.common.collect.ImmutableMap;
@@ -71,7 +71,7 @@ import javax.annotation.Nullable;
*
* @author Colin Decker
*/
-public final class StandardAttributeProviders {
+final class StandardAttributeProviders {
private StandardAttributeProviders() {}
diff --git a/jimfs/src/main/java/com/google/jimfs/attribute/UnixAttributeProvider.java b/jimfs/src/main/java/com/google/jimfs/UnixAttributeProvider.java
index ffacf8b..3a6d3c2 100644
--- a/jimfs/src/main/java/com/google/jimfs/attribute/UnixAttributeProvider.java
+++ b/jimfs/src/main/java/com/google/jimfs/UnixAttributeProvider.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.attribute;
+package com.google.jimfs;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -75,14 +75,14 @@ final class UnixAttributeProvider extends AttributeProvider {
}
@Override
- public UnixFileAttributeView view(Inode.Lookup lookup,
+ public UnixFileAttributeView view(FileLookup lookup,
ImmutableMap<String, FileAttributeView> inheritedViews) {
// This method should not be called... and it cannot be called through the public APIs in
// java.nio.file since there is no public UnixFileAttributeView type.
throw new UnsupportedOperationException();
}
- // TODO(cgdecker): Since we can now guarantee that the owner/group for an inode are our own
+ // TODO(cgdecker): Since we can now guarantee that the owner/group for an file are our own
// implementation of UserPrincipal/GroupPrincipal, it would be nice to have them store a unique
// ID themselves and just get that rather than doing caching here. Then this could be a singleton
// like the rest of the AttributeProviders. However, that would require a way for the owner/posix
@@ -106,28 +106,28 @@ final class UnixAttributeProvider extends AttributeProvider {
@SuppressWarnings("unchecked")
@Override
- public Object get(Inode inode, String attribute) {
+ public Object get(File file, String attribute) {
switch (attribute) {
case "uid":
- UserPrincipal user = (UserPrincipal) inode.getAttribute("owner", "owner");
+ UserPrincipal user = (UserPrincipal) file.getAttribute("owner", "owner");
return getUniqueId(user);
case "gid":
- GroupPrincipal group = (GroupPrincipal) inode.getAttribute("posix", "group");
+ GroupPrincipal group = (GroupPrincipal) file.getAttribute("posix", "group");
return getUniqueId(group);
case "mode":
Set<PosixFilePermission> permissions =
- (Set<PosixFilePermission>) inode.getAttribute("posix", "permissions");
+ (Set<PosixFilePermission>) file.getAttribute("posix", "permissions");
return toMode(permissions);
case "ctime":
- return FileTime.fromMillis(inode.getCreationTime());
+ return FileTime.fromMillis(file.getCreationTime());
case "rdev":
return 0L;
case "dev":
return 1L;
case "ino":
- return inode.id();
+ return file.id();
case "nlink":
- return inode.links();
+ return file.links();
default:
return null;
}
@@ -135,7 +135,7 @@ final class UnixAttributeProvider extends AttributeProvider {
@Override
public void set(
- Inode inode, String view, String attribute, Object value, boolean create) {
+ File file, String view, String attribute, Object value, boolean create) {
throw unsettable(view, attribute);
}
diff --git a/jimfs/src/main/java/com/google/jimfs/attribute/UnixFileAttributeView.java b/jimfs/src/main/java/com/google/jimfs/UnixFileAttributeView.java
index eec48ac..54d79db 100644
--- a/jimfs/src/main/java/com/google/jimfs/attribute/UnixFileAttributeView.java
+++ b/jimfs/src/main/java/com/google/jimfs/UnixFileAttributeView.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.attribute;
+package com.google.jimfs;
import java.nio.file.attribute.FileAttributeView;
diff --git a/jimfs/src/main/java/com/google/jimfs/path/UnixPathType.java b/jimfs/src/main/java/com/google/jimfs/UnixPathType.java
index da22cf9..11ca6bd 100644
--- a/jimfs/src/main/java/com/google/jimfs/path/UnixPathType.java
+++ b/jimfs/src/main/java/com/google/jimfs/UnixPathType.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.path;
+package com.google.jimfs;
import static com.google.common.base.Preconditions.checkArgument;
diff --git a/jimfs/src/main/java/com/google/jimfs/attribute/UserDefinedAttributeProvider.java b/jimfs/src/main/java/com/google/jimfs/UserDefinedAttributeProvider.java
index f9cc5f5..f98fe25 100644
--- a/jimfs/src/main/java/com/google/jimfs/attribute/UserDefinedAttributeProvider.java
+++ b/jimfs/src/main/java/com/google/jimfs/UserDefinedAttributeProvider.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.attribute;
+package com.google.jimfs;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -57,21 +57,21 @@ final class UserDefinedAttributeProvider extends AttributeProvider {
}
@Override
- public ImmutableSet<String> attributes(Inode inode) {
- return userDefinedAttributes(inode);
+ public ImmutableSet<String> attributes(File file) {
+ return userDefinedAttributes(file);
}
- private static ImmutableSet<String> userDefinedAttributes(Inode inode) {
+ private static ImmutableSet<String> userDefinedAttributes(File file) {
ImmutableSet.Builder<String> builder = ImmutableSet.builder();
- for (String attribute : inode.getAttributeNames("user")) {
+ for (String attribute : file.getAttributeNames("user")) {
builder.add(attribute);
}
return builder.build();
}
@Override
- public Object get(Inode inode, String attribute) {
- Object value = inode.getAttribute("user", attribute);
+ public Object get(File file, String attribute) {
+ Object value = file.getAttribute("user", attribute);
if (value instanceof byte[]) {
byte[] bytes = (byte[]) value;
return bytes.clone();
@@ -80,7 +80,7 @@ final class UserDefinedAttributeProvider extends AttributeProvider {
}
@Override
- public void set(Inode inode, String view, String attribute, Object value,
+ public void set(File file, String view, String attribute, Object value,
boolean create) {
checkNotNull(value);
checkNotCreate(view, attribute, create);
@@ -97,7 +97,7 @@ final class UserDefinedAttributeProvider extends AttributeProvider {
throw invalidType(view, attribute, value, byte[].class, ByteBuffer.class);
}
- inode.setAttribute("user", attribute, bytes);
+ file.setAttribute("user", attribute, bytes);
}
@Override
@@ -106,7 +106,7 @@ final class UserDefinedAttributeProvider extends AttributeProvider {
}
@Override
- public UserDefinedFileAttributeView view(Inode.Lookup lookup,
+ public UserDefinedFileAttributeView view(FileLookup lookup,
ImmutableMap<String, FileAttributeView> inheritedViews) {
return new View(lookup);
}
@@ -116,7 +116,7 @@ final class UserDefinedAttributeProvider extends AttributeProvider {
*/
private static class View extends AbstractAttributeView implements UserDefinedFileAttributeView {
- public View(Inode.Lookup lookup) {
+ public View(FileLookup lookup) {
super(lookup);
}
@@ -127,11 +127,11 @@ final class UserDefinedAttributeProvider extends AttributeProvider {
@Override
public List<String> list() throws IOException {
- return userDefinedAttributes(lookupInode()).asList();
+ return userDefinedAttributes(lookupFile()).asList();
}
private byte[] getStoredBytes(String name) throws IOException {
- byte[] bytes = (byte[]) lookupInode().getAttribute(name(), name);
+ byte[] bytes = (byte[]) lookupFile().getAttribute(name(), name);
if (bytes == null) {
throw new IllegalArgumentException("attribute '" + name() + ":" + name + "' is not set");
}
@@ -154,13 +154,13 @@ final class UserDefinedAttributeProvider extends AttributeProvider {
public int write(String name, ByteBuffer src) throws IOException {
byte[] bytes = new byte[src.remaining()];
src.get(bytes);
- lookupInode().setAttribute(name(), name, bytes);
+ lookupFile().setAttribute(name(), name, bytes);
return bytes.length;
}
@Override
public void delete(String name) throws IOException {
- lookupInode().deleteAttribute(name(), name);
+ lookupFile().deleteAttribute(name(), name);
}
}
}
diff --git a/jimfs/src/main/java/com/google/jimfs/internal/UserLookupService.java b/jimfs/src/main/java/com/google/jimfs/UserLookupService.java
index d115b03..398346e 100644
--- a/jimfs/src/main/java/com/google/jimfs/internal/UserLookupService.java
+++ b/jimfs/src/main/java/com/google/jimfs/UserLookupService.java
@@ -14,9 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.internal;
-
-import com.google.jimfs.attribute.UserPrincipals;
+package com.google.jimfs;
import java.io.IOException;
import java.nio.file.attribute.GroupPrincipal;
diff --git a/jimfs/src/main/java/com/google/jimfs/attribute/UserPrincipals.java b/jimfs/src/main/java/com/google/jimfs/UserPrincipals.java
index 2bcb846..7ec71f7 100644
--- a/jimfs/src/main/java/com/google/jimfs/attribute/UserPrincipals.java
+++ b/jimfs/src/main/java/com/google/jimfs/UserPrincipals.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.attribute;
+package com.google.jimfs;
import static com.google.common.base.Preconditions.checkNotNull;
diff --git a/jimfs/src/main/java/com/google/jimfs/internal/Util.java b/jimfs/src/main/java/com/google/jimfs/Util.java
index 84698bf..cc77f12 100644
--- a/jimfs/src/main/java/com/google/jimfs/internal/Util.java
+++ b/jimfs/src/main/java/com/google/jimfs/Util.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.internal;
+package com.google.jimfs;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
diff --git a/jimfs/src/main/java/com/google/jimfs/path/WindowsPathType.java b/jimfs/src/main/java/com/google/jimfs/WindowsPathType.java
index de040df..d44e371 100644
--- a/jimfs/src/main/java/com/google/jimfs/path/WindowsPathType.java
+++ b/jimfs/src/main/java/com/google/jimfs/WindowsPathType.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.google.jimfs.path;
+package com.google.jimfs;
import java.nio.file.InvalidPathException;
import java.util.Iterator;
diff --git a/jimfs/src/main/java/com/google/jimfs/attribute/package-info.java b/jimfs/src/main/java/com/google/jimfs/attribute/package-info.java
deleted file mode 100644
index 92774b8..0000000
--- a/jimfs/src/main/java/com/google/jimfs/attribute/package-info.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2013 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Package containing classes used for configuration of
- * <a href="https://www.google.com/url?sa=D&q=http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FFile_attribute">file attribute</a> handling.
- *
- * <p>Users can create a subclass of
- * {@link com.google.jimfs.attribute.AttributeProvider AttributeProvider} to implement handling of
- * a custom file attribute view. In an attribute provider, the
- * {@link com.google.jimfs.attribute.Inode Inode} class is used to access and set file attributes.
- *
- * <p>{@link com.google.jimfs.attribute.StandardAttributeProviders StandardAttributeProvideres}
- * provides access to the standard set of {@code AttributeProvider} implementations that JimFS
- * supports.
- */
-@ParametersAreNonnullByDefault
-package com.google.jimfs.attribute;
-
-import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file
diff --git a/jimfs/src/main/java/com/google/jimfs/internal/File.java b/jimfs/src/main/java/com/google/jimfs/internal/File.java
deleted file mode 100644
index fb86725..0000000
--- a/jimfs/src/main/java/com/google/jimfs/internal/File.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright 2013 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.jimfs.internal;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import com.google.common.base.Objects;
-import com.google.jimfs.attribute.Inode;
-
-/**
- * A file object, containing both the file's metadata and a reference to its content.
- *
- * @author Colin Decker
- */
-final class File extends Inode {
-
- /*
- * While conceptually this class should not extend Inode (instead the inode ID should be used
- * elsewhere to locate the file content), it makes the most sense here to extend Inode because it
- * makes locating the content easier (it's referenced directly from the inode) and because it
- * allows the size() method to get the size directly from the content rather than having to store
- * the size itself and have it updated every time the size changes.
- */
-
- private final FileContent content;
-
- public File(int id, FileContent content) {
- super(id);
- this.content = checkNotNull(content);
- }
-
- /**
- * Returns the content of this file.
- */
- public FileContent content() {
- return content;
- }
-
- @Override
- public long size() {
- return content.size();
- }
-
- @Override
- public boolean isDirectory() {
- return content instanceof DirectoryTable;
- }
-
- @Override
- public boolean isRegularFile() {
- return content instanceof ByteStore;
- }
-
- @Override
- public boolean isSymbolicLink() {
- return content instanceof JimfsPath;
- }
-
- /**
- * Returns whether or not this file is a root directory of the file system.
- */
- public boolean isRootDirectory() {
- // only root directories have their parent link pointing to themselves
- return isDirectory() && equals(asDirectory().parent());
- }
-
- /**
- * Returns a view of this file as a byte store.
- */
- public ByteStore asBytes() {
- return (ByteStore) content;
- }
-
- /**
- * Returns a view of this file as a directory table.
- */
- public DirectoryTable asDirectory() {
- return (DirectoryTable) content;
- }
-
- /**
- * Gets the target of this symbolic link.
- */
- public JimfsPath asTargetPath() {
- return (JimfsPath) content;
- }
-
- @Override
- public String toString() {
- return Objects.toStringHelper(this)
- .add("id", id())
- .add("contentType", content.getClass().getSimpleName())
- .toString();
- }
-}
diff --git a/jimfs/src/main/java/com/google/jimfs/internal/JimfsFileSystem.java b/jimfs/src/main/java/com/google/jimfs/internal/JimfsFileSystem.java
deleted file mode 100644
index f46e4b5..0000000
--- a/jimfs/src/main/java/com/google/jimfs/internal/JimfsFileSystem.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * Copyright 2013 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.jimfs.internal;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.ImmutableSortedSet;
-import com.google.common.util.concurrent.ThreadFactoryBuilder;
-
-import java.io.Closeable;
-import java.io.IOException;
-import java.net.URI;
-import java.nio.file.FileStore;
-import java.nio.file.FileSystem;
-import java.nio.file.Path;
-import java.nio.file.PathMatcher;
-import java.nio.file.WatchService;
-import java.nio.file.attribute.UserPrincipalLookupService;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-import javax.annotation.Nullable;
-
-/**
- * {@link FileSystem} implementation for JimFS. Most behavior for the file system is implemented
- * by its {@linkplain #getDefaultView() default file system view}.
- *
- * @author Colin Decker
- */
-final class JimfsFileSystem extends FileSystem {
-
- private final JimfsFileSystemProvider provider;
- private final URI uri;
-
- private final JimfsFileStore fileStore;
- private final PathService pathService;
-
- private final ResourceManager resourceManager = new ResourceManager();
- private final UserPrincipalLookupService userLookupService = new UserLookupService(true);
-
- private final FileSystemView defaultView;
-
- JimfsFileSystem(JimfsFileSystemProvider provider, URI uri, JimfsFileStore fileStore,
- PathService pathService, FileSystemView defaultView) {
- this.provider = checkNotNull(provider);
- this.uri = checkNotNull(uri);
- this.fileStore = checkNotNull(fileStore);
- this.pathService = checkNotNull(pathService);
- this.defaultView = checkNotNull(defaultView);
- }
-
- @Override
- public JimfsFileSystemProvider provider() {
- return provider;
- }
-
- /**
- * Returns the URI for this file system.
- */
- public URI getUri() {
- return uri;
- }
-
- /**
- * Returns the default view for this file system.
- */
- public FileSystemView getDefaultView() {
- return defaultView;
- }
-
- @Override
- public String getSeparator() {
- return pathService.getSeparator();
- }
-
- @SuppressWarnings("unchecked") // safe cast of immutable set
- @Override
- public ImmutableSortedSet<Path> getRootDirectories() {
- ImmutableSortedSet.Builder<JimfsPath> builder = ImmutableSortedSet.orderedBy(pathService);
- for (Name name : fileStore.getRootDirectoryNames()) {
- builder.add(pathService.createRoot(name));
- }
- return (ImmutableSortedSet<Path>) (ImmutableSortedSet<?>) builder.build();
- }
-
- /**
- * Returns the working directory path for this file system.
- */
- public JimfsPath getWorkingDirectory() {
- return defaultView.getWorkingDirectoryPath();
- }
-
- /**
- * Returns the path service for this file system.
- */
- @VisibleForTesting
- PathService getPathService() {
- return pathService;
- }
-
- /**
- * Returns the file store for this file system.
- */
- public JimfsFileStore getFileStore() {
- return fileStore;
- }
-
- @Override
- public ImmutableSet<FileStore> getFileStores() {
- return ImmutableSet.<FileStore>of(fileStore);
- }
-
- @Override
- public ImmutableSet<String> supportedFileAttributeViews() {
- return fileStore.supportedFileAttributeViews();
- }
-
- @Override
- public JimfsPath getPath(String first, String... more) {
- return pathService.parsePath(first, more);
- }
-
- /**
- * Gets the URI of the given path in this file system.
- */
- public URI toUri(JimfsPath path) {
- return pathService.toUri(uri, path.toAbsolutePath());
- }
-
- /**
- * Converts the given URI into a path in this file system.
- */
- public JimfsPath toPath(URI uri) {
- return pathService.fromUri(uri);
- }
-
- @Override
- public PathMatcher getPathMatcher(String syntaxAndPattern) {
- return pathService.createPathMatcher(syntaxAndPattern);
- }
-
- @Override
- public UserPrincipalLookupService getUserPrincipalLookupService() {
- return userLookupService;
- }
-
- @Override
- public synchronized WatchService newWatchService() throws IOException {
- // synchronized for resourceManager to register the watch service so there are no races between
- // creating a watch service and closing the file system
- return new PollingWatchService(defaultView, pathService, resourceManager);
- }
-
- @Nullable
- private ExecutorService defaultThreadPool;
-
- /**
- * Returns a default thread pool to use for asynchronous file channels when users do not provide
- * an executor themselves. (This is required by the spec of newAsynchronousFileChannel in
- * FileSystemProvider.)
- */
- public synchronized ExecutorService getDefaultThreadPool() {
- if (defaultThreadPool == null) {
- defaultThreadPool = Executors.newCachedThreadPool(new ThreadFactoryBuilder()
- .setDaemon(true)
- .setNameFormat("JimfsFileSystem-" + uri.getHost() + "-defaultThreadPool-%s")
- .build());
-
- // ensure thread pool is closed when file system is closed
- resourceManager.register(new Closeable() {
- @Override
- public void close() {
- defaultThreadPool.shutdown();
- }
- });
- }
- return defaultThreadPool;
- }
-
- /**
- * Returns {@code false}; currently, cannot create a read-only file system.
- *
- * @return {@code false}, always
- */
- @Override
- public boolean isReadOnly() {
- return false;
- }
-
- private boolean open = true;
-
- @Override
- public synchronized boolean isOpen() {
- return open;
- }
-
- @Override
- public synchronized void close() throws IOException {
- if (open) {
- open = false;
- try {
- resourceManager.close();
- } finally {
- provider.remove(this);
- }
- }
- }
-}
diff --git a/jimfs/src/main/java/com/google/jimfs/internal/package-info.java b/jimfs/src/main/java/com/google/jimfs/internal/package-info.java
deleted file mode 100644
index 7cef362..0000000
--- a/jimfs/src/main/java/com/google/jimfs/internal/package-info.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Copyright 2013 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Package containing the internal implementation of the JimFS file system. With the exception of
- * {@link com.google.jimfs.internal.JimfsFileSystemProvider JimfsFileSystemProvider}, which should
- * not be used directly anyway, all classes in this package are package-private.
- *
- * <h3>Overview</h3>
- *
- * {@link com.google.jimfs.internal.JimfsFileSystem JimfsFileSystem} instances are created by
- * {@link com.google.jimfs.internal.JimfsFileSystems JimfsFileSystems} using a user-provided
- * {@link com.google.jimfs.Configuration Configuration}. The configuration is used to create the
- * various classes that implement the file system with the correct settings and to create the file
- * system root directories and working directory. The file system is then used to create the
- * {@code Path} objects that all file system operations use.
- *
- * <p>Once created, the primary entry points to the file system are
- * {@link com.google.jimfs.internal.JimfsFileSystemProvider JimfsFileSystemProvider}, which handles
- * calls to methods in {@link java.nio.file.Files}, and
- * {@link com.google.jimfs.internal.JimfsSecureDirectoryStream JimfsSecureDirectoryStream}, which
- * provides methods that are similar to those of the file system provider but which treat relative
- * paths as relative to the stream's directory rather than the file system's working directory.
- *
- * <p>The implementation of the methods on both of those classes is handled by the
- * {@link com.google.jimfs.internal.FileSystemView FileSystemView} class, which acts as a view of
- * the file system with a specific working directory. The file system provider uses the file
- * system's default view, while each secure directory stream uses a view specific to that stream.
- *
- * <p>File system views make use of the file system's singleton
- * {@link com.google.jimfs.internal.JimfsFileStore JimfsFileStore} which handles file creation,
- * storage and attributes. The file store delegates to several other classes to handle each of
- * these:
- *
- * <ul>
- * <li>{@link com.google.jimfs.internal.FileFactory FileFactory} handles creation of new file
- * objects.</li>
- * <li>{@link com.google.jimfs.internal.HeapDisk HeapDisk} handles creation and storage of
- * {@link com.google.jimfs.internal.ByteStore ByteStore} instances, which act as the content of
- * regular files.</li>
- * <li>{@link com.google.jimfs.internal.FileTree FileTree} stores the root of the file hierarchy
- * and handles file lookup.</li>
- * <li>{@link com.google.jimfs.internal.AttributeService AttributeService} handles file
- * attributes, using a set of
- * {@link com.google.jimfs.attribute.AttributeProvider AttributeProvider} implementations to
- * handle each supported file attribute view.</li>
- * </ul>
- *
- * <h3>Paths</h3>
- *
- * The implementation of {@link java.nio.file.Path} for the file system is
- * {@link com.google.jimfs.internal.JimfsPath JimfsPath}. Paths are created by a
- * {@link com.google.jimfs.internal.PathService PathService} with help from the file system's
- * configured {@link com.google.jimfs.path.PathType PathType}.
- *
- * <p>Paths are made up of {@link com.google.jimfs.internal.Name Name} objects, which also serve as
- * the file names in directories. A name has two forms:
- *
- * <ul>
- * <li>The <b>display form</b> is used in {@code Path} for {@code toString()}. It is also used for
- * determining the equality and sort order of {@code Path} objects for most file systems.</li>
- * <li>The <b>canonical form</b> is used for equality of two {@code Name} objects. This affects
- * the notion of name equality in the file system itself for file lookup. A file system may be
- * configured to use the canonical form of the name for path equality (a Windows-like file system
- * configuration does this, as the real Windows file system implementation uses case-insensitive
- * equality for its path objects.</li>
- * </ul>
- *
- * <p>The canonical form of a name is created by applying a series of
- * {@linkplain com.google.jimfs.path.Normalization normalizations} to the original string. These
- * normalization may be either a Unicode normalization (e.g. NFD) or case folding normalization for
- * case-insensitivity. Normalizations may also be applied to the display form of a name, but this
- * is currently only done for a Mac OS X type configuration.
- *
- * <h3>Files</h3>
- *
- * All files in the file system are an instance of {@link com.google.jimfs.internal.File File}. A
- * file object contains the file's attributes as well as a reference to the file's
- * {@linkplain com.google.jimfs.internal.FileContent content}.
- *
- * <p>There are three types of file content:
- *
- * <ul>
- * <li>{@link com.google.jimfs.internal.DirectoryTable DirectoryTable} - a map linking file names
- * to {@linkplain com.google.jimfs.internal.DirectoryEntry directory entries}. A file with a
- * directory table as its content is, obviously, a <i>directory</i>.</li>
- * <li>{@link com.google.jimfs.internal.ByteStore ByteStore} - an in-memory store for raw bytes.
- * A file with a byte store as its content is a <i>regular file</i>.</li>
- * <li>{@link com.google.jimfs.internal.JimfsPath JimfsPath} - A file with a path as its content
- * is a <i>symbolic link</i>.</li>
- * </ul>
- *
- * <p>{@link com.google.jimfs.internal.JimfsFileChannel JimfsFileChannel},
- * {@link com.google.jimfs.internal.JimfsInputStream JimfsInputStream} and
- * {@link com.google.jimfs.internal.JimfsOutputStream JimfsOutputStream} implement the standard
- * channel/stream APIs for regular files.
- *
- * <p>{@link com.google.jimfs.internal.JimfsDirectoryStream JimfsDirectoryStream} and
- * {@link com.google.jimfs.internal.JimfsSecureDirectoryStream JimfsSecureDirectoryStream} handle
- * reading the entries of a directory. The secure directory stream additionally contains a
- * {@code FileSystemView} with its directory as the working directory, allowing for operations
- * relative to the actual directory file rather than just the path to the file. This allows the
- * operations to continue to work as expected even if the directory is moved.
- *
- * <p>A directory can be watched for changes using the {@link java.nio.file.WatchService}
- * implementation, {@link com.google.jimfs.internal.PollingWatchService PollingWatchService}.
- *
- * <h3>Regular files</h3>
- *
- * Currently, the only implementation for regular file content is
- * {@link com.google.jimfs.internal.ByteStore ByteStore}, which makes use of a singleton
- * {@link com.google.jimfs.internal.HeapDisk HeapDisk}. A disk is a resizable factory and cache for
- * fixed size blocks of memory. These blocks are allocated to files as needed and returned to the
- * disk when a file is deleted or truncated. When cached free blocks are available, those blocks
- * are allocated to files first. If more blocks are needed, they are created.
- *
- * <h3>Linking</h3>
- *
- * When a file is mapped to a file name in a directory table, it is <i>linked</i>. Each type of
- * file has different rules governing how it is linked.
- *
- * <ul>
- * <li>Directory - A directory has two or more links to it. The first is the link from
- * its parent directory to it. This link is the name of the directory. The second is the
- * <i>self</i> link (".") which links the directory to itself. The directory may also have any
- * number of additional <i>parent</i> links ("..") from child directories back to it.</li>
- * <li>Regular file - A regular file has one link from its parent directory by default. However,
- * regular files are also allowed to have any number of additional user-created hard links, from
- * the same directory with different names and/or from other directories with any names.</li>
- * <li>Symbolic link - A symbolic link can only have one link, from its parent directory.</li>
- * </ul>
- *
- * <h3>Thread safety</h3>
- *
- * All file system operations should be safe in a multithreaded environment. The file hierarchy
- * itself is protected by a file system level read-write lock. This ensures safety of all
- * modifications to directory tables as well as atomicity of operations like file moves. Regular
- * files are each protected by a read-write lock on their content which is obtained for each read
- * or write operation. File attributes are not protected by locks, but are stored in thread-safe
- * concurrent maps and atomic numbers.
- */
-@ParametersAreNonnullByDefault
-package com.google.jimfs.internal;
-
-import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file
diff --git a/jimfs/src/main/resources/META-INF/services/java.nio.file.spi.FileSystemProvider b/jimfs/src/main/resources/META-INF/services/java.nio.file.spi.FileSystemProvider
index 32a08a5..79532c4 100644
--- a/jimfs/src/main/resources/META-INF/services/java.nio.file.spi.FileSystemProvider
+++ b/jimfs/src/main/resources/META-INF/services/java.nio.file.spi.FileSystemProvider
@@ -1 +1 @@
-com.google.jimfs.internal.JimfsFileSystemProvider \ No newline at end of file
+com.google.jimfs.JimfsFileSystemProvider \ No newline at end of file