Package ch.pontius.nio.smb
Class SMBFileSystem
- java.lang.Object
-
- java.nio.file.FileSystem
-
- ch.pontius.nio.smb.SMBFileSystem
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public final class SMBFileSystem extends java.nio.file.FileSystemThis class represents a single SMB server (filesystem). The authority part of the SMB URI creates a uniqueSMBFileSystem, that is, if you connect to the same server with different credentials, it will results in two distincSMBFileSysteminstances. Furthermore, different names for the same server will result in differentSMBFileSysteminstances too. TheSMBFileSystemis the factory for several types of objects, likeSMBPath,SMBFileStoreetc.- Since:
- 1.0
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Removes the current instance ofSMBFileSystemfrom theSMBFileSystemProvider's cache.java.lang.Iterable<java.nio.file.FileStore>getFileStores()Returns theSMBFileStores, i.e.java.nio.file.PathgetPath(java.lang.String first, java.lang.String... more)Constructs a newSMBPathby concatenating the provided path components.java.nio.file.PathMatchergetPathMatcher(java.lang.String syntaxAndPattern)Returns a newSMBPathMatcherfor the provided pattern.java.lang.Iterable<java.nio.file.Path>getRootDirectories()Returns the root directories, i.e.java.lang.StringgetSeparator()Returns the default path sepeator, which is "/".java.nio.file.attribute.UserPrincipalLookupServicegetUserPrincipalLookupService()UserPrincipalLookupServiceare not supported by the current version ofSMBFileSystem.booleanisOpen()Returns true, if the currentSMBFileSystemis still known to theSMBFileSystemProvider.booleanisReadOnly()Returns false because generally,SMBFileSystem's are not considered to be read-only.java.nio.file.WatchServicenewWatchService()WatchServiceare not supported by the current version ofSMBFileSystem.java.nio.file.spi.FileSystemProviderprovider()Returns instance ofSMBFileSystemProviderthisSMBFileSystembelongs to.java.util.Set<java.lang.String>supportedFileAttributeViews()Returns a containing the names of the supportedFileAttributeViews
-
-
-
Method Detail
-
provider
public java.nio.file.spi.FileSystemProvider provider()
Returns instance ofSMBFileSystemProviderthisSMBFileSystembelongs to.- Specified by:
providerin classjava.nio.file.FileSystem- Returns:
SMBFileSystemProvider
-
close
public void close()
Removes the current instance ofSMBFileSystemfrom theSMBFileSystemProvider's cache. Calling this method will not actually close any underlying resource. However, existing paths pointing to the current instance ofSMBFileSystemwill not be handled to the- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein classjava.nio.file.FileSystem
-
isOpen
public boolean isOpen()
Returns true, if the currentSMBFileSystemis still known to theSMBFileSystemProvider.- Specified by:
isOpenin classjava.nio.file.FileSystem- Returns:
- If current
SMBFileSystemis still open.
-
isReadOnly
public boolean isReadOnly()
Returns false because generally,SMBFileSystem's are not considered to be read-only. However, the concrete access permissions are specific to a file or resource.- Specified by:
isReadOnlyin classjava.nio.file.FileSystem- Returns:
- false
-
getSeparator
public java.lang.String getSeparator()
Returns the default path sepeator, which is "/".- Specified by:
getSeparatorin classjava.nio.file.FileSystem- Returns:
- "/"
-
getRootDirectories
public java.lang.Iterable<java.nio.file.Path> getRootDirectories()
Returns the root directories, i.e. the list of shares, provided by the currentSMBFileSystem.- Specified by:
getRootDirectoriesin classjava.nio.file.FileSystem- Returns:
- List of shares for the current
SMBFileSystem.
-
getFileStores
public java.lang.Iterable<java.nio.file.FileStore> getFileStores()
Returns theSMBFileStores, i.e. the list of shares, provided by the currentSMBFileSystem.- Specified by:
getFileStoresin classjava.nio.file.FileSystem- Returns:
- List of
SMBFileStores for the currentSMBFileSystem.
-
supportedFileAttributeViews
public java.util.Set<java.lang.String> supportedFileAttributeViews()
Returns a containing the names of the supportedFileAttributeViews- Specified by:
supportedFileAttributeViewsin classjava.nio.file.FileSystem- Returns:
- Set with the names of the supported
FileAttributeViews.
-
getPath
public java.nio.file.Path getPath(java.lang.String first, java.lang.String... more)Constructs a newSMBPathby concatenating the provided path components. If the first path starts with a '/' the newly constructed path will be an absolute path. If the last component ends with a '/' the path is treated as a folder.- Specified by:
getPathin classjava.nio.file.FileSystem- Parameters:
first- First path component.more- List of additional path components.- Returns:
- Constructed
SMBPath.
-
getPathMatcher
public java.nio.file.PathMatcher getPathMatcher(java.lang.String syntaxAndPattern)
Returns a newSMBPathMatcherfor the provided pattern.- Specified by:
getPathMatcherin classjava.nio.file.FileSystem- Parameters:
syntaxAndPattern- The syntax or pattern that should be used to match paths against.- Returns:
SMBPathMatcher
-
getUserPrincipalLookupService
public java.nio.file.attribute.UserPrincipalLookupService getUserPrincipalLookupService()
UserPrincipalLookupServiceare not supported by the current version ofSMBFileSystem.- Specified by:
getUserPrincipalLookupServicein classjava.nio.file.FileSystem- Throws:
java.lang.UnsupportedOperationException- Always
-
newWatchService
public java.nio.file.WatchService newWatchService()
WatchServiceare not supported by the current version ofSMBFileSystem.- Specified by:
newWatchServicein classjava.nio.file.FileSystem- Throws:
java.lang.UnsupportedOperationException- Always
-
-