APIdia Launch Partner
Top Description Inners Fields Constructors Methods
sun.nio.fs

pack-priv abstract Class UnixFileSystem

extends FileSystem
Class Inheritance
Known Direct Subclasses
sun.nio.fs.LinuxFileSystem
Imports
java.nio.ByteBuffer, java.nio.file.AtomicMoveNotSupportedException, .CopyOption, .DirectoryNotEmptyException, .FileAlreadyExistsException, .FileStore, .FileSystem, .FileSystemException, .LinkOption, .Path, .PathMatcher, .StandardCopyOption, java.nio.file.attribute.GroupPrincipal, .UserPrincipal, .UserPrincipalLookupService, java.nio.file.spi.FileSystemProvider, java.io.IOException, java.util.Arrays, .Collections, .Iterator, .List, .NoSuchElementException, .Objects, java.util.concurrent.ExecutionException, .TimeUnit, java.util.regex.Pattern, sun.nio.ch.DirectBuffer, .IOStatus

Base implementation of FileSystem for Unix-like implementations.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
UnixFileSystem.FileStoreIterator

Iterator returned by getFileStores method.

protected static class
private static class

Field Summary

Modifier and TypeField and Description
private final byte[]
private static volatile boolean
private static final String
private static final int
private final boolean
private final UnixFileSystemProvider
private static final String
private final UnixPath

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv void
bufferedCopy(int
destination file descriptor
dst
,
int
source file descriptor
src
,
long
the address of the temporary direct buffer's array
address
,
int
the size of the temporary direct buffer's array
size
,
long
address to check for cancellation (a non-zero value written to this address indicates cancel)
addressToPollForCancel
)

Copies data between file descriptors src and dst using an intermediate temporary direct buffer.

private static native void
bufferedCopy0(int dst, int src, long address, int size, long addressToPollForCancel)

public final void
close()

Implements abstract java.nio.file.FileSystem.close.

Implements java.io.Closeable.close.

Closes this file system.

pack-priv Pattern
pack-priv void
copy(final UnixPath source, final UnixPath target, CopyOption... options)

private void
pack-priv void
copyFile(UnixPath source, UnixFileAttributes attrs, UnixPath target, UnixFileSystem.Flags flags, long addressToPollForCancel)

pack-priv void
copyNonPosixAttributes(int
Open file descriptor to source file
sfd
,
int
Open file descriptor to target file
tfd
)

Copies non-POSIX attributes from the source to target file.

private void
pack-priv byte[]
pack-priv int

Returns:

0 on success, IOStatus.UNAVAILABLE if the platform function would block, IOStatus.UNSUPPORTED_CASE if the call does not work with the given parameters, or IOStatus.UNSUPPORTED if direct copying is not supported on this platform
directCopy
(int
destination file descriptor
dst
,
int
source file descriptor
src
,
long
address to check for cancellation (a non-zero value written to this address indicates cancel)
addressToPollForCancel
)

Copies data between file descriptors src and dst using a platform-specific function or system call possibly having kernel support.

pack-priv static void
pack-priv abstract FileStore
getFileStore(UnixMountEntry entry)

Returns a FileStore to represent the file system for the given mount mount.

public final Iterable<FileStore>
getFileStores()

Implements abstract java.nio.file.FileSystem.getFileStores.

Returns an object to iterate over the underlying file stores.

pack-priv abstract Iterable<UnixMountEntry>
getMountEntries()

Returns object to iterate over entries in mounttab or equivalent

public final Path
getPath(String first, String... more)

Implements abstract java.nio.file.FileSystem.getPath.

Converts a path string, or a sequence of strings that when joined form a path string, to a Path.

public PathMatcher
getPathMatcher(String syntaxAndInput)

Implements abstract java.nio.file.FileSystem.getPathMatcher.

Returns a PathMatcher that performs match operations on the String representation of Path objects by interpreting a given pattern.

public final Iterable<Path>
getRootDirectories()

Implements abstract java.nio.file.FileSystem.getRootDirectories.

Unix systems only have a single root directory (/)

public final String
getSeparator()

Implements abstract java.nio.file.FileSystem.getSeparator.

Returns the name separator, represented as a string.

public final UserPrincipalLookupService
getUserPrincipalLookupService()

Implements abstract java.nio.file.FileSystem.getUserPrincipalLookupService.

Returns the UserPrincipalLookupService for this file system (optional operation).

pack-priv boolean
public final boolean
isOpen()

Implements abstract java.nio.file.FileSystem.isOpen.

Tells whether or not this file system is open.

public final boolean
isReadOnly()

Implements abstract java.nio.file.FileSystem.isReadOnly.

Tells whether or not this file system allows only read-only access to its file stores.

private static long
lcm(long x, long y)

pack-priv void
move(UnixPath source, UnixPath target, CopyOption... options)

pack-priv boolean
public final FileSystemProvider
provider()

Implements abstract java.nio.file.FileSystem.provider.

Returns the provider that created this file system.

pack-priv UnixPath
pack-priv static List<String>
private static int
Inherited from java.nio.file.FileSystem:
newWatchServicesupportedFileAttributeViews

Field Detail

defaultDirectoryback to summary
private final byte[] defaultDirectory
directCopyNotSupportedback to summary
private static volatile boolean directCopyNotSupported
GLOB_SYNTAXback to summary
private static final String GLOB_SYNTAX
MIN_BUFFER_SIZEback to summary
private static final int MIN_BUFFER_SIZE
needToResolveAgainstDefaultDirectoryback to summary
private final boolean needToResolveAgainstDefaultDirectory
providerback to summary
private final UnixFileSystemProvider provider
REGEX_SYNTAXback to summary
private static final String REGEX_SYNTAX
rootDirectoryback to summary
private final UnixPath rootDirectory

Constructor Detail

UnixFileSystemback to summary
pack-priv UnixFileSystem(UnixFileSystemProvider provider, String dir)

Method Detail

bufferedCopyback to summary
pack-priv void bufferedCopy(int dst, int src, long address, int size, long addressToPollForCancel) throws UnixException

Copies data between file descriptors src and dst using an intermediate temporary direct buffer.

Parameters
dst:int

destination file descriptor

src:int

source file descriptor

address:long

the address of the temporary direct buffer's array

size:int

the size of the temporary direct buffer's array

addressToPollForCancel:long

address to check for cancellation (a non-zero value written to this address indicates cancel)

bufferedCopy0back to summary
private static native void bufferedCopy0(int dst, int src, long address, int size, long addressToPollForCancel) throws UnixException
closeback to summary
public final void close() throws IOException

Implements abstract java.nio.file.FileSystem.close.

Implements java.io.Closeable.close.

Doc from java.nio.file.FileSystem.close.

Closes this file system.

After a file system is closed then all subsequent access to the file system, either by methods defined by this class or on objects associated with this file system, throw ClosedFileSystemException. If the file system is already closed then invoking this method has no effect.

Closing a file system will close all open channels, directory-streams, watch-service, and other closeable objects associated with this file system. The default file system cannot be closed.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
compilePathMatchPatternback to summary
pack-priv Pattern compilePathMatchPattern(String expr)
copyback to summary
pack-priv void copy(final UnixPath source, final UnixPath target, CopyOption... options) throws IOException
copyDirectoryback to summary
private void copyDirectory(UnixPath source, UnixFileAttributes attrs, UnixPath target, UnixFileSystem.Flags flags) throws IOException
copyFileback to summary
pack-priv void copyFile(UnixPath source, UnixFileAttributes attrs, UnixPath target, UnixFileSystem.Flags flags, long addressToPollForCancel) throws IOException
copyNonPosixAttributesback to summary
pack-priv void copyNonPosixAttributes(int sfd, int tfd)

Copies non-POSIX attributes from the source to target file. Copying a file preserving attributes, or moving a file, will preserve the file owner/group/permissions/timestamps but it does not preserve other non-POSIX attributes. This method is invoked by the copy or move operation to preserve these attributes. It should copy extended attributes, ACLs, or other attributes.

Parameters
sfd:int

Open file descriptor to source file

tfd:int

Open file descriptor to target file

copySpecialback to summary
private void copySpecial(UnixPath source, UnixFileAttributes attrs, UnixPath target, UnixFileSystem.Flags flags) throws IOException
defaultDirectoryback to summary
pack-priv byte[] defaultDirectory()
directCopyback to summary
pack-priv int directCopy(int dst, int src, long addressToPollForCancel) throws UnixException

Copies data between file descriptors src and dst using a platform-specific function or system call possibly having kernel support.

Parameters
dst:int

destination file descriptor

src:int

source file descriptor

addressToPollForCancel:long

address to check for cancellation (a non-zero value written to this address indicates cancel)

Returns:int

0 on success, IOStatus.UNAVAILABLE if the platform function would block, IOStatus.UNSUPPORTED_CASE if the call does not work with the given parameters, or IOStatus.UNSUPPORTED if direct copying is not supported on this platform

ensureEmptyDirback to summary
pack-priv static void ensureEmptyDir(UnixPath dir) throws IOException
getFileStoreback to summary
pack-priv abstract FileStore getFileStore(UnixMountEntry entry) throws IOException

Returns a FileStore to represent the file system for the given mount mount.

getFileStoresback to summary
public final Iterable<FileStore> getFileStores()

Implements abstract java.nio.file.FileSystem.getFileStores.

Doc from java.nio.file.FileSystem.getFileStores.

Returns an object to iterate over the underlying file stores.

The elements of the returned iterator are the FileStores for this file system. The order of the elements is not defined and the file stores may change during the lifetime of the Java virtual machine. When an I/O error occurs, perhaps because a file store is not accessible, then it is not returned by the iterator.

Usage Example: Suppose we want to print the space usage for all file stores:

for (FileStore store: FileSystems.getDefault().getFileStores()) { long total = store.getTotalSpace() / 1024; long used = (store.getTotalSpace() - store.getUnallocatedSpace()) / 1024; long avail = store.getUsableSpace() / 1024; System.out.format("%-20s %12d %12d %12d%n", store, total, used, avail); }
for (FileStore store: FileSystems.getDefault().getFileStores()) {
    long total = store.getTotalSpace() / 1024;
    long used = (store.getTotalSpace() - store.getUnallocatedSpace()) / 1024;
    long avail = store.getUsableSpace() / 1024;
    System.out.format("%-20s %12d %12d %12d%n", store, total, used, avail);
}
Annotations
@Override
getMountEntriesback to summary
pack-priv abstract Iterable<UnixMountEntry> getMountEntries()

Returns object to iterate over entries in mounttab or equivalent

getPathback to summary
public final Path getPath(String first, String... more)

Implements abstract java.nio.file.FileSystem.getPath.

Doc from java.nio.file.FileSystem.getPath.

Converts a path string, or a sequence of strings that when joined form a path string, to a Path. If more does not specify any elements then the value of the first parameter is the path string to convert. If more specifies one or more elements then each non-empty string, including first, is considered to be a sequence of name elements (see Path) and is joined to form a path string. The details as to how the Strings are joined is provider specific but typically they will be joined using the name-separator as the separator. For example, if the name separator is "/" and getPath("/foo","bar","gus") is invoked, then the path string "/foo/bar/gus" is converted to a Path. A Path representing an empty path is returned if first is the empty string and more does not contain any non-empty strings.

The parsing and conversion to a path object is inherently implementation dependent. In the simplest case, the path string is rejected, and InvalidPathException thrown, if the path string contains characters that cannot be converted to characters that are legal to the file store. For example, on UNIX systems, the NUL (\u0000) character is not allowed to be present in a path. An implementation may choose to reject path strings that contain names that are longer than those allowed by any file store, and where an implementation supports a complex path syntax, it may choose to reject path strings that are badly formed.

In the case of the default provider, path strings are parsed based on the definition of paths at the platform or virtual file system level. For example, an operating system may not allow specific characters to be present in a file name, but a specific underlying file store may impose different or additional restrictions on the set of legal characters.

This method throws InvalidPathException when the path string cannot be converted to a path. Where possible, and where applicable, the exception is created with an index value indicating the first position in the path parameter that caused the path string to be rejected.

Annotations
@Override
getPathMatcherback to summary
public PathMatcher getPathMatcher(String syntaxAndInput)

Implements abstract java.nio.file.FileSystem.getPathMatcher.

Doc from java.nio.file.FileSystem.getPathMatcher.

Returns a PathMatcher that performs match operations on the String representation of Path objects by interpreting a given pattern. The syntaxAndPattern parameter identifies the syntax and the pattern and takes the form:

syntax:pattern
where syntax is the non-empty name of the syntax, pattern is a possibly-empty pattern string, and ':' stands for itself.

A FileSystem implementation supports the "glob" and "regex" syntaxes, and may support others. The value of the syntax component is compared without regard to case.

When the syntax is "glob" then the String representation of the path is matched using a limited pattern language that resembles regular expressions but with a simpler syntax. For example:

Pattern Language
Example Description
*.java Matches a path that represents a file name ending in .java
*.* Matches file names containing a dot
*.{java,class} Matches file names ending with .java or .class
foo.? Matches file names starting with foo. and a single character extension
/home/*/* Matches /home/gus/data on UNIX platforms
/home/** Matches /home/gus and /home/gus/data on UNIX platforms
C:\\* Matches C:\foo and C:\bar on the Windows platform (note that the backslash is escaped; as a string literal in the Java Language the pattern would be "C:\\\\*")

The following rules are used to interpret glob patterns:

  • The * character matches zero or more characters of a name component without crossing directory boundaries.

  • The ** characters matches zero or more characters crossing directory boundaries.

  • The ? character matches exactly one character of a name component.

  • The backslash character (\) is used to escape characters that would otherwise be interpreted as special characters. The expression \\ matches a single backslash and "\{" matches a left brace for example.

  • The [ ] characters are a bracket expression that match a single character of a name component out of a set of characters. For example, [abc] matches "a", "b", or "c". The hyphen (-) may be used to specify a range so [a-z] specifies a range that matches from "a" to "z" (inclusive). These forms can be mixed so [abce-g] matches "a", "b", "c", "e", "f" or "g". If the character after the [ is a ! then it is used for negation so [!a-c] matches any character except "a", "b", or "c".

    Within a bracket expression the *, ? and \ characters match themselves. The (-) character matches itself if it is the first character within the brackets, or the first character after the ! if negating.

  • The { } characters are a group of subpatterns, where the group matches if any subpattern in the group matches. The "," character is used to separate the subpatterns. Groups cannot be nested.

  • Leading period/dot characters in file name are treated as regular characters in match operations. For example, the "*" glob pattern matches file name ".login". The Files#isHidden method may be used to test whether a file is considered hidden.

  • All other characters match themselves in an implementation dependent manner. This includes characters representing any name-separators.

  • The matching of root components is highly implementation-dependent and is not specified.

When the syntax is "regex" then the pattern component is a regular expression as defined by the java.util.regex.Pattern class.

For both the glob and regex syntaxes, the matching details, such as whether the matching is case sensitive, are implementation-dependent and therefore not specified.

Annotations
@Override
getRootDirectoriesback to summary
public final Iterable<Path> getRootDirectories()

Implements abstract java.nio.file.FileSystem.getRootDirectories.

Unix systems only have a single root directory (/)

Annotations
@Override
getSeparatorback to summary
public final String getSeparator()

Implements abstract java.nio.file.FileSystem.getSeparator.

Doc from java.nio.file.FileSystem.getSeparator.

Returns the name separator, represented as a string.

The name separator is used to separate names in a path string. An implementation may support multiple name separators in which case this method returns an implementation specific default name separator. This separator is used when creating path strings by invoking the toString() method.

In the case of the default provider, this method returns the same separator as java.io.File#separator.

Annotations
@Override
getUserPrincipalLookupServiceback to summary
public final UserPrincipalLookupService getUserPrincipalLookupService()

Implements abstract java.nio.file.FileSystem.getUserPrincipalLookupService.

Doc from java.nio.file.FileSystem.getUserPrincipalLookupService.

Returns the UserPrincipalLookupService for this file system (optional operation). The resulting lookup service may be used to lookup user or group names.

Usage Example: Suppose we want to make "joe" the owner of a file:

UserPrincipalLookupService lookupService = FileSystems.getDefault().getUserPrincipalLookupService(); Files.setOwner(path, lookupService.lookupPrincipalByName("joe"));
UserPrincipalLookupService lookupService = FileSystems.getDefault().getUserPrincipalLookupService();
Files.setOwner(path, lookupService.lookupPrincipalByName("joe"));
Annotations
@Override
isCaseInsensitiveAndPreservingback to summary
pack-priv boolean isCaseInsensitiveAndPreserving()
isOpenback to summary
public final boolean isOpen()

Implements abstract java.nio.file.FileSystem.isOpen.

Doc from java.nio.file.FileSystem.isOpen.

Tells whether or not this file system is open.

File systems created by the default provider are always open.

Annotations
@Override
isReadOnlyback to summary
public final boolean isReadOnly()

Implements abstract java.nio.file.FileSystem.isReadOnly.

Doc from java.nio.file.FileSystem.isReadOnly.

Tells whether or not this file system allows only read-only access to its file stores.

Annotations
@Override
lcmback to summary
private static long lcm(long x, long y)
moveback to summary
pack-priv void move(UnixPath source, UnixPath target, CopyOption... options) throws IOException
needToResolveAgainstDefaultDirectoryback to summary
pack-priv boolean needToResolveAgainstDefaultDirectory()
providerback to summary
public final FileSystemProvider provider()

Implements abstract java.nio.file.FileSystem.provider.

Doc from java.nio.file.FileSystem.provider.

Returns the provider that created this file system.

Annotations
@Override
rootDirectoryback to summary
pack-priv UnixPath rootDirectory()
standardFileAttributeViewsback to summary
pack-priv static List<String> standardFileAttributeViews()
temporaryBufferSizeback to summary
private static int temporaryBufferSize(UnixPath source, UnixPath target)
sun.nio.fs back to summary

private Class UnixFileSystem.FileStoreIterator

extends Object
implements Iterator<FileStore>
Class Inheritance
All Implemented Interfaces
java.util.Iterator

Iterator returned by getFileStores method.

Field Summary

Modifier and TypeField and Description
private final Iterator<UnixMountEntry>
private FileStore

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public synchronized boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.

public synchronized FileStore
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.

private FileStore
public void
remove()

Overrides default java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

entriesback to summary
private final Iterator<UnixMountEntry> entries
nextback to summary
private FileStore next

Constructor Detail

FileStoreIteratorback to summary
pack-priv FileStoreIterator()

Method Detail

hasNextback to summary
public synchronized boolean hasNext()

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Annotations
@Override
nextback to summary
public synchronized FileStore next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Annotations
@Override
readNextback to summary
private FileStore readNext()
removeback to summary
public void remove()

Overrides default java.util.Iterator.remove.

Doc from java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation). This method can be called only once per call to next.

The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.

The behavior of an iterator is unspecified if this method is called after a call to the forEachRemaining method.

Annotations
@Override
sun.nio.fs back to summary

protected Class UnixFileSystem.Flags

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv boolean
pack-priv boolean
pack-priv boolean
pack-priv boolean
pack-priv boolean
pack-priv boolean
pack-priv boolean
pack-priv boolean
pack-priv boolean
pack-priv boolean

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
pack-priv static UnixFileSystem.Flags
pack-priv static UnixFileSystem.Flags
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

atomicMoveback to summary
pack-priv boolean atomicMove
copyBasicAttributesback to summary
pack-priv boolean copyBasicAttributes
copyNonPosixAttributesback to summary
pack-priv boolean copyNonPosixAttributes
copyPosixAttributesback to summary
pack-priv boolean copyPosixAttributes
failIfUnableToCopyBasicback to summary
pack-priv boolean failIfUnableToCopyBasic
failIfUnableToCopyNonPosixback to summary
pack-priv boolean failIfUnableToCopyNonPosix
failIfUnableToCopyPosixback to summary
pack-priv boolean failIfUnableToCopyPosix
interruptibleback to summary
pack-priv boolean interruptible
replaceExistingback to summary
pack-priv boolean replaceExisting

Constructor Detail

Flagsback to summary
protected Flags()

Method Detail

fromCopyOptionsback to summary
pack-priv static UnixFileSystem.Flags fromCopyOptions(CopyOption... options)
fromMoveOptionsback to summary
pack-priv static UnixFileSystem.Flags fromMoveOptions(CopyOption... options)
sun.nio.fs back to summary

private Class UnixFileSystem.LookupService

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv static final UserPrincipalLookupService

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

instanceback to summary
pack-priv static final UserPrincipalLookupService instance

Constructor Detail

LookupServiceback to summary
private LookupService()