Class SmbFile
- java.lang.Object
-
- java.net.URLConnection
-
- jcifs.smb.SmbFile
-
- All Implemented Interfaces:
AutoCloseable,SmbConstants,SmbResource
- Direct Known Subclasses:
SmbNamedPipe
public class SmbFile extends URLConnection implements SmbResource, SmbConstants
This class represents a resource on an SMB network. Mainly these resources are files and directories however anSmbFilemay also refer to servers and workgroups. If the resource is a file or directory the methods ofSmbFilefollow the behavior of the well knownFileclass. One fundamental difference is the usage of a URL scheme [1] to specify the target file or directory. SmbFile URLs have the following syntax:
This example:smb://[[[domain;]username[:password]@]server[:port]/[[share/[dir/]file]]][?param=value[param2=value2[...]]]
would reference the filesmb://storage15/public/foo.txtfoo.txtin the sharepublicon the serverstorage15. In addition to referencing files and directories, jCIFS can also address servers, and workgroups.Important: all SMB URLs that represent workgroups, servers, shares, or directories require a trailing slash '/'.
When using the java.net.URL class with 'smb://' URLs it is necessary to first call the static jcifs.Config.registerSmbURLHandler(); method. This is required to register the SMB protocol handler.
The userinfo component of the SMB URL (domain;user:pass) must be URL encoded if it contains reserved characters. According to RFC 2396 these characters are non US-ASCII characters and most meta characters however jCIFS will work correctly with anything but '@' which is used to delimit the userinfo component from the server and '%' which is the URL escape character itself.
The server component may a traditional NetBIOS name, a DNS name, or IP address. These name resolution mechanisms and their resolution order can be changed (See Setting Name Resolution Properties). The servername and path components are not case sensitive but the domain, username, and password components are. It is also likely that properties must be specified for jcifs to function (See Setting JCIFS Properties). Here are some examples of SMB URLs with brief descriptions of what they do:
[1] This URL scheme is based largely on the SMB Filesharing URL Scheme IETF draft.
SMB URL Examples URL Description smb://users-nyc;miallen:mypass@angus/tmp/This URL references a share called tmpon the serverangusas usermiallenwho's password ismypass.smb://Administrator:P%40ss@msmith1/c/WINDOWS/Desktop/foo.txtA relatively sophisticated example that references a file msmith1's desktop as userAdministrator. Notice the '@' is URL encoded with the '%40' hexcode escape.smb://angus/This references only a server. The behavior of some methods is different in this context(e.g. you cannot deletea server) however as you might expect thelistmethod will list the available shares on this server.smb://angus.foo.net/d/jcifs/pipes.docThe server name may also be a DNS name as it is in this example. See Setting Name Resolution Properties for details. smb://192.168.1.15/ADMIN$/The server name may also be an IP address. See Setting Name Resolution Properties for details. smb://domain;username:password@server/share/path/to/file.txtA prototypical example that uses all the fields. smb://server/share/path/to/dir <-- ILLEGALURLs that represent servers, shares, or directories require a trailing slash '/'. A second constructor argument may be specified to augment the URL for better programmatic control when processing many files under a common base. This is slightly different from the corresponding
java.io.Fileusage; a '/' at the beginning of the second parameter will still use the server component of the first parameter. The examples below illustrate the resulting URLs when this second constructor argument is used.Examples Of SMB URLs When Augmented With A Second Constructor Parameter First Parameter Second Parameter Result smb://host/share/a/b/c/d/smb://host/share/a/b/c/d/smb://host/share/foo/bar//share2/zig/zagsmb://host/share2/zig/zagsmb://host/share/foo/bar/../zip/smb://host/share/foo/zip/smb://host/share/zig/zagsmb://foo/bar/smb://foo/bar/smb://host/share/foo/../.././.././../foo/smb://host/foo/smb://host/share/zig/zag/smb://host/smb://server/../smb://server/Instances of the
SmbFileclass are immutable; that is, once created, the abstract pathname represented by an SmbFile object will never change.- See Also:
File
-
-
Field Summary
Fields Modifier and Type Field Description protected static intATTR_GET_MASKprotected static intATTR_SET_MASKprotected static intDEFAULT_ATTR_EXPIRATION_PERIODprotected jcifs.smb.SmbResourceLocatorImplfileLocatorprotected static intHASH_DOTprotected static intHASH_DOT_DOT-
Fields inherited from class java.net.URLConnection
allowUserInteraction, connected, doInput, doOutput, ifModifiedSince, url, useCaches
-
Fields inherited from interface jcifs.SmbConstants
ATTR_ARCHIVE, ATTR_COMPRESSED, ATTR_DIRECTORY, ATTR_HIDDEN, ATTR_NORMAL, ATTR_READONLY, ATTR_SYSTEM, ATTR_TEMPORARY, ATTR_VOLUME, CAP_DFS, CAP_EXTENDED_SECURITY, CAP_LARGE_FILES, CAP_LARGE_READX, CAP_LARGE_WRITEX, CAP_LEVEL_II_OPLOCKS, CAP_LOCK_AND_READ, CAP_MPX_MODE, CAP_NONE, CAP_NT_FIND, CAP_NT_SMBS, CAP_RAW_MODE, CAP_RPC_REMOTE_APIS, CAP_STATUS32, CAP_UNICODE, CMD_OFFSET, DEFAULT_CONN_TIMEOUT, DEFAULT_MAX_MPX_COUNT, DEFAULT_NOTIFY_BUF_SIZE, DEFAULT_OEM_ENCODING, DEFAULT_PORT, DEFAULT_RCV_BUF_SIZE, DEFAULT_RESPONSE_TIMEOUT, DEFAULT_SHARING, DEFAULT_SND_BUF_SIZE, DEFAULT_SO_TIMEOUT, DEFAULT_SSN_LIMIT, DELETE, ERROR_CODE_OFFSET, FILE_APPEND_DATA, FILE_DELETE, FILE_EXECUTE, FILE_NO_SHARE, FILE_READ_ATTRIBUTES, FILE_READ_DATA, FILE_READ_EA, FILE_SHARE_DELETE, FILE_SHARE_READ, FILE_SHARE_WRITE, FILE_WRITE_ATTRIBUTES, FILE_WRITE_DATA, FILE_WRITE_EA, FLAGS_COPY_SOURCE_MODE_ASCII, FLAGS_COPY_TARGET_MODE_ASCII, FLAGS_LOCK_AND_READ_WRITE_AND_UNLOCK, FLAGS_NONE, FLAGS_NOTIFY_OF_MODIFY_ACTION, FLAGS_OFFSET, FLAGS_OPLOCK_REQUESTED_OR_GRANTED, FLAGS_PATH_NAMES_CANONICALIZED, FLAGS_PATH_NAMES_CASELESS, FLAGS_RECEIVE_BUFFER_POSTED, FLAGS_RESPONSE, FLAGS_TARGET_MUST_BE_DIRECTORY, FLAGS_TARGET_MUST_BE_FILE, FLAGS_TREE_COPY, FLAGS_VERIFY_ALL_WRITES, FLAGS2_EXTENDED_ATTRIBUTES, FLAGS2_EXTENDED_SECURITY_NEGOTIATION, FLAGS2_LONG_FILENAMES, FLAGS2_NONE, FLAGS2_PERMIT_READ_IF_EXECUTE_PERM, FLAGS2_RESOLVE_PATHS_IN_DFS, FLAGS2_SECURITY_REQUIRE_SIGNATURES, FLAGS2_SECURITY_SIGNATURES, FLAGS2_STATUS32, FLAGS2_UNICODE, FOREVER, GENERIC_ALL, GENERIC_EXECUTE, GENERIC_READ, GENERIC_WRITE, MILLISECONDS_BETWEEN_1970_AND_1601, O_APPEND, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY, OPEN_FUNCTION_FAIL_IF_EXISTS, OPEN_FUNCTION_OVERWRITE_IF_EXISTS, READ_CONTROL, SECURITY_SHARE, SECURITY_USER, SIGNATURE_OFFSET, SMB1_HEADER_LENGTH, SYNCHRONIZE, TID_OFFSET, TYPE_COMM, TYPE_FILESYSTEM, TYPE_NAMED_PIPE, TYPE_PRINTER, TYPE_SERVER, TYPE_SHARE, TYPE_WORKGROUP, WRITE_DAC, WRITE_OWNER
-
-
Constructor Summary
Constructors Constructor Description SmbFile(String url)Deprecated.SmbFile(String url, CIFSContext tc)Construct from string URLSmbFile(URL url)Deprecated.SmbFile(URL url, CIFSContext tc)Construct from URLSmbFile(SmbResource context, String name)Constructs an SmbFile representing a resource on an SMB network such as a file or directory.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleancanRead()Tests to see if the file thisSmbResourcerepresents can be read.booleancanWrite()Tests to see if the file thisSmbResourcerepresents exists and is not marked read-only.CloseableIterator<SmbResource>children()Fetch all childrenCloseableIterator<SmbResource>children(String wildcard)Fetch children matching pattern, server-side filteringCloseableIterator<SmbResource>children(ResourceFilter filter)CloseableIterator<SmbResource>children(ResourceNameFilter filter)voidclose()Close/release the file This releases all resources that this file holds.voidconnect()voidcopyTo(SmbResource d)This method will copy the file or directory represented by this SmbResource and it's sub-contents to the location specified by the dest parameter.voidcreateNewFile()Create a new file but fail if it already exists.longcreateTime()Retrieve the time thisSmbResourcewas created.protected voidcustomizeCreate(SmbComNTCreateAndX request, SmbComNTCreateAndXResponse response)voiddelete()This method will delete the file or directory specified by thisSmbResource.booleanequals(Object obj)Tests to see if twoSmbFileobjects are equal.booleanexists()Tests to see if the SMB resource exists.longfileIndex()Get the file indexintgetAttributes()Return the attributes of this file.StringgetCanonicalPath()Returns the full URL of this SMB resource with '.' and '..' components factored out.StringgetCanonicalUncPath()Returns the Windows UNC style path with backslashes instead of forward slashes.intgetContentLength()Deprecated.longgetContentLengthLong()CIFSContextgetContext()The context this file was opened withlonggetDate()This URLConnection method just returns the result of lastModified.StringgetDfsPath()If the path of thisSmbFilefalls within a DFS volume, this method will return the referral path to which it maps.longgetDiskFreeSpace()This method returns the free disk space in bytes of the drive this share represents or the drive on which the directory or file resides.InputStreamgetInputStream()This URLConnection method just returns a new SmbFileInputStream created with this file.longgetLastModified()This URLConnection method just returns the result of lastModified.SmbResourceLocatorgetLocator()Gets the file locator for this file The file locator provides details aboutStringgetName()Returns the last component of the target URL.OutputStreamgetOutputStream()SIDgetOwnerGroup()Return the resolved owner group SID for this file or directorySIDgetOwnerGroup(boolean resolve)Return the owner group SID for this file or directorySIDgetOwnerUser()Return the resolved owner user SID for this file or directorySIDgetOwnerUser(boolean resolve)Return the owner user SID for this file or directoryStringgetParent()Everything but the last component of the URL representing this SMB resource is effectively it's parent.StringgetPath()Returns the full uncanonicalized URL of this SMB resource.ACE[]getSecurity()Return an array of Access Control Entry (ACE) objects representing the security descriptor associated with this file or directory.ACE[]getSecurity(boolean resolveSids)Return an array of Access Control Entry (ACE) objects representing the security descriptor associated with this file or directory.StringgetServer()Retrieve the hostname of the server for this SMB resource.StringgetServerWithDfs()Retrieve the hostname of the server for this SMB resource.StringgetShare()Retrieves the share associated with this SMB resource.ACE[]getShareSecurity(boolean resolveSids)Return an array of Access Control Entry (ACE) objects representing the share permissions on the share exporting this file or directory.CIFSContextgetTransportContext()Deprecated.SmbTreeHandlegetTreeHandle()intgetType()Returns type of of object this SmbResource represents.StringgetUncPath()inthashCode()Computes a hashCode for this file based on the URL string and IP address if the server.booleanisDirectory()Tests to see if the file thisSmbResourcerepresents is a directory.booleanisFile()Tests to see if the file thisSmbResourcerepresents is not a directory.booleanisHidden()Tests to see if the file this SmbResource represents is marked as hidden.longlastAccess()Retrieve the last acces time of the file represented by thisSmbResourcelonglastModified()Retrieve the last time the file represented by thisSmbResourcewas modified.longlength()Returns the length of this SmbResource in bytes.String[]list()List the contents of this SMB resource.String[]list(SmbFilenameFilter filter)List the contents of this SMB resource.SmbFile[]listFiles()List the contents of this SMB resource as an array ofSmbResourceobjects.SmbFile[]listFiles(String wildcard)The CIFS protocol provides for DOS "wildcards" to be used as a performance enhancement.SmbFile[]listFiles(SmbFileFilter filter)List the contents of this SMB resource.SmbFile[]listFiles(SmbFilenameFilter filter)List the contents of this SMB resource.voidmkdir()Creates a directory with the path specified by thisSmbResource.voidmkdirs()Creates a directory with the path specified by this SmbResource and any parent directories that do not exist.SmbFileInputStreamopenInputStream()Opens an input stream reading the file (read only, sharable)SmbFileInputStreamopenInputStream(int sharing)Opens an input stream reading the file (read only)SmbFileInputStreamopenInputStream(int flags, int access, int sharing)Opens an input stream reading the file (read only)SmbFileOutputStreamopenOutputStream()Opens an output stream writing to the file (truncating, write only, sharable)SmbFileOutputStreamopenOutputStream(boolean append)Opens an output stream writing to the file (write only, read sharable)SmbFileOutputStreamopenOutputStream(boolean append, int sharing)Opens an output stream writing to the file (write only, exclusive write access)SmbFileOutputStreamopenOutputStream(boolean append, int openFlags, int access, int sharing)Opens an output stream writing to the file (write only, exclusive write access)SmbRandomAccessFileopenRandomAccess(String mode)Opens the file for random accessSmbRandomAccessFileopenRandomAccess(String mode, int sharing)Opens the file for random accessvoidrenameTo(SmbResource d)Changes the name of the file thisSmbResourcerepresents to the name designated by theSmbResourceargument.voidrenameTo(SmbResource d, boolean replace)Changes the name of the file thisSmbResourcerepresents to the name designated by theSmbResourceargument.SmbResourceresolve(String name)Fetch a child resourcevoidsetAttributes(int attrs)Set the attributes of this file.voidsetCreateTime(long time)Set the create time of the file.voidsetFileTimes(long createTime, long lastLastModified, long lastLastAccess)Set the create, last modified and last access time of the file.voidsetLastAccess(long time)Set the last access time of the file.voidsetLastModified(long time)Set the last modified time of the file.protected voidsetNonPooled(boolean nonPooled)voidsetReadOnly()Make this file read-only.voidsetReadWrite()Turn off the read-only attribute of this file.StringtoString()Returns the string representation of this SmbFile object.URLtoURL()Deprecated.Use getURL() insteadSmbWatchHandlewatch(int filter, boolean recursive)Creates a directory watch The server will notify the client when there are changes to the directories contentsprotected <T extends ServerMessageBlock2Response>
TwithOpen(jcifs.smb.SmbTreeHandleImpl th, int createDisposition, int createOptions, int fileAttributes, int desiredAccess, int shareAccess, ServerMessageBlock2Request<T> first, ServerMessageBlock2Request<?>... others)protected <T extends ServerMessageBlock2Response>
TwithOpen(jcifs.smb.SmbTreeHandleImpl th, int createDisposition, int desiredAccess, int shareAccess, ServerMessageBlock2Request<T> first, ServerMessageBlock2Request<?>... others)protected <T extends ServerMessageBlock2Response>
TwithOpen(jcifs.smb.SmbTreeHandleImpl th, ServerMessageBlock2Request<T> first, ServerMessageBlock2Request<?>... others)-
Methods inherited from class java.net.URLConnection
addRequestProperty, getAllowUserInteraction, getConnectTimeout, getContent, getContent, getContentEncoding, getContentType, getDefaultAllowUserInteraction, getDefaultRequestProperty, getDefaultUseCaches, getDefaultUseCaches, getDoInput, getDoOutput, getExpiration, getFileNameMap, getHeaderField, getHeaderField, getHeaderFieldDate, getHeaderFieldInt, getHeaderFieldKey, getHeaderFieldLong, getHeaderFields, getIfModifiedSince, getPermission, getReadTimeout, getRequestProperties, getRequestProperty, getURL, getUseCaches, guessContentTypeFromName, guessContentTypeFromStream, setAllowUserInteraction, setConnectTimeout, setContentHandlerFactory, setDefaultAllowUserInteraction, setDefaultRequestProperty, setDefaultUseCaches, setDefaultUseCaches, setDoInput, setDoOutput, setFileNameMap, setIfModifiedSince, setReadTimeout, setRequestProperty, setUseCaches
-
-
-
-
Field Detail
-
ATTR_GET_MASK
protected static final int ATTR_GET_MASK
- See Also:
- Constant Field Values
-
ATTR_SET_MASK
protected static final int ATTR_SET_MASK
- See Also:
- Constant Field Values
-
DEFAULT_ATTR_EXPIRATION_PERIOD
protected static final int DEFAULT_ATTR_EXPIRATION_PERIOD
- See Also:
- Constant Field Values
-
HASH_DOT
protected static final int HASH_DOT
-
HASH_DOT_DOT
protected static final int HASH_DOT_DOT
-
fileLocator
protected final jcifs.smb.SmbResourceLocatorImpl fileLocator
-
-
Constructor Detail
-
SmbFile
@Deprecated public SmbFile(String url) throws MalformedURLException
Deprecated.Constructs an SmbFile representing a resource on an SMB network such as a file or directory. See the description and examples of smb URLs above.- Parameters:
url- A URL string- Throws:
MalformedURLException- If theparentandchildparameters do not follow the prescribed syntax
-
SmbFile
@Deprecated public SmbFile(URL url) throws MalformedURLException
Deprecated.Constructs an SmbFile representing a resource on an SMB network such as a file or directory from a URL object.- Parameters:
url- The URL of the target resource- Throws:
MalformedURLException
-
SmbFile
public SmbFile(SmbResource context, String name) throws MalformedURLException, UnknownHostException
Constructs an SmbFile representing a resource on an SMB network such as a file or directory. The second parameter is a relative path from theparent SmbFile. See the description above for examples of using the secondnameparameter.- Parameters:
context- A baseSmbFilename- A path string relative to theparentparameter- Throws:
MalformedURLException- If theparentandchildparameters do not follow the prescribed syntaxUnknownHostException- If the server or workgroup of the context file cannot be determined
-
SmbFile
public SmbFile(String url, CIFSContext tc) throws MalformedURLException
Construct from string URL- Parameters:
url-tc- context to use- Throws:
MalformedURLException
-
SmbFile
public SmbFile(URL url, CIFSContext tc) throws MalformedURLException
Construct from URL- Parameters:
url-tc- context to use- Throws:
MalformedURLException
-
-
Method Detail
-
connect
public void connect() throws IOException- Specified by:
connectin classURLConnection- Throws:
IOException- See Also:
URLConnection.connect()
-
getTreeHandle
public SmbTreeHandle getTreeHandle() throws CIFSException
- Returns:
- a tree handle
- Throws:
CIFSException
-
close
public void close()
Close/release the file This releases all resources that this file holds. If not using strict mode this is currently a no-op.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceSmbResource- See Also:
AutoCloseable.close()
-
setNonPooled
protected void setNonPooled(boolean nonPooled)
- Parameters:
nonPooled- whether this file will use an exclusive connection
-
getTransportContext
@Deprecated public CIFSContext getTransportContext()
Deprecated.- Returns:
- the transportContext
-
getContext
public CIFSContext getContext()
Description copied from interface:SmbResourceThe context this file was opened with- Specified by:
getContextin interfaceSmbResource- Returns:
- the context associated with this file
-
getLocator
public SmbResourceLocator getLocator()
Description copied from interface:SmbResourceGets the file locator for this file The file locator provides details about- Specified by:
getLocatorin interfaceSmbResource- Returns:
- the fileLocator
-
resolve
public SmbResource resolve(String name) throws CIFSException
Description copied from interface:SmbResourceFetch a child resource- Specified by:
resolvein interfaceSmbResource- Returns:
- the child resource
- Throws:
CIFSException
-
getUncPath
public String getUncPath()
- Returns:
- this file's unc path below the share
-
customizeCreate
protected void customizeCreate(SmbComNTCreateAndX request, SmbComNTCreateAndXResponse response)
- Parameters:
request-response-
-
exists
public boolean exists() throws SmbExceptionDescription copied from interface:SmbResourceTests to see if the SMB resource exists. If the resource refers only to a server, this method determines if the server exists on the network and is advertising SMB services. If this resource refers to a workgroup, this method determines if the workgroup name is valid on the local SMB network. If thisSmbResourcerefers to the rootsmb://resourcetrueis always returned. If thisSmbResourceis a traditional file or directory, it will be queried for on the specified server as expected.- Specified by:
existsin interfaceSmbResource- Returns:
trueif the resource exists or is alive orfalseotherwise- Throws:
SmbException
-
getType
public int getType() throws SmbExceptionDescription copied from interface:SmbResourceReturns type of of object this SmbResource represents.- Specified by:
getTypein interfaceSmbResource- Returns:
- TYPE_FILESYSTEM, TYPE_WORKGROUP, TYPE_SERVER, TYPE_SHARE, TYPE_PRINTER, TYPE_NAMED_PIPE, or TYPE_COMM.
- Throws:
SmbException
-
getName
public String getName()
Description copied from interface:SmbResourceReturns the last component of the target URL. This will effectively be the name of the file or directory represented by thisSmbResourceor in the case of URLs that only specify a server or workgroup, the server or workgroup will be returned. The name of the root URLsmb://is alsosmb://. If this SmbResource refers to a workgroup, server, share, or directory, the name will include a trailing slash '/' so that composing new SmbResources will maintain the trailing slash requirement.- Specified by:
getNamein interfaceSmbResource- Returns:
- The last component of the URL associated with this SMB
resource or
smb://if the resource issmb://itself.
-
getParent
public String getParent()
Everything but the last component of the URL representing this SMB resource is effectively it's parent. The root URLsmb://does not have a parent. In this casesmb://is returned.- Returns:
- The parent directory of this SMB resource or
smb://if the resource refers to the root of the URL hierarchy which incidentally is alsosmb://.
-
getPath
public String getPath()
Returns the full uncanonicalized URL of this SMB resource. AnSmbFileconstructed with the result of this method will result in anSmbFilethat is equal to the original.- Returns:
- The uncanonicalized full URL of this SMB resource.
-
getCanonicalUncPath
public String getCanonicalUncPath()
Returns the Windows UNC style path with backslashes instead of forward slashes.- Returns:
- The UNC path.
-
getDfsPath
public String getDfsPath() throws SmbException
If the path of thisSmbFilefalls within a DFS volume, this method will return the referral path to which it maps. Otherwisenullis returned.- Returns:
- URL to the DFS volume
- Throws:
SmbException
-
getCanonicalPath
public String getCanonicalPath()
Returns the full URL of this SMB resource with '.' and '..' components factored out. AnSmbFileconstructed with the result of this method will result in anSmbFilethat is equal to the original.- Returns:
- The canonicalized URL of this SMB resource.
-
getShare
public String getShare()
Retrieves the share associated with this SMB resource. In the case ofsmb://,smb://workgroup/, andsmb://server/URLs which do not specify a share,nullwill be returned.- Returns:
- The share component or
nullif there is no share
-
getServerWithDfs
public String getServerWithDfs()
Retrieve the hostname of the server for this SMB resource. If the resources has been resolved by DFS this will return the target name.- Returns:
- The server name
-
getServer
public String getServer()
Retrieve the hostname of the server for this SMB resource. If thisSmbFilereferences a workgroup, the name of the workgroup is returned. If thisSmbFilerefers to the root of this SMB network hierarchy,nullis returned.- Returns:
- The server or workgroup name or
nullif thisSmbFilerefers to the rootsmb://resource.
-
watch
public SmbWatchHandle watch(int filter, boolean recursive) throws CIFSException
Description copied from interface:SmbResourceCreates a directory watch The server will notify the client when there are changes to the directories contents- Specified by:
watchin interfaceSmbResource- Parameters:
filter- see constants inFileNotifyInformationrecursive- whether to also watch subdirectories- Returns:
- watch context, needs to be closed when finished
- Throws:
CIFSException
-
canRead
public boolean canRead() throws SmbExceptionDescription copied from interface:SmbResourceTests to see if the file thisSmbResourcerepresents can be read. Because any file, directory, or other resource can be read if it exists, this method simply calls theexistsmethod.- Specified by:
canReadin interfaceSmbResource- Returns:
trueif the file is read-only- Throws:
SmbException
-
canWrite
public boolean canWrite() throws SmbExceptionDescription copied from interface:SmbResourceTests to see if the file thisSmbResourcerepresents exists and is not marked read-only. By default, resources are considered to be read-only and therefore forsmb://,smb://workgroup/, andsmb://server/resources will be read-only.- Specified by:
canWritein interfaceSmbResource- Returns:
trueif the resource exists is not marked read-only- Throws:
SmbException
-
isDirectory
public boolean isDirectory() throws SmbExceptionDescription copied from interface:SmbResourceTests to see if the file thisSmbResourcerepresents is a directory.- Specified by:
isDirectoryin interfaceSmbResource- Returns:
trueif thisSmbResourceis a directory- Throws:
SmbException
-
isFile
public boolean isFile() throws SmbExceptionDescription copied from interface:SmbResourceTests to see if the file thisSmbResourcerepresents is not a directory.- Specified by:
isFilein interfaceSmbResource- Returns:
trueif thisSmbResourceis not a directory- Throws:
SmbException
-
isHidden
public boolean isHidden() throws SmbExceptionDescription copied from interface:SmbResourceTests to see if the file this SmbResource represents is marked as hidden. This method will also return true for shares with names that end with '$' such asIPC$orC$.- Specified by:
isHiddenin interfaceSmbResource- Returns:
trueif theSmbResourceis marked as being hidden- Throws:
SmbException
-
createTime
public long createTime() throws SmbExceptionDescription copied from interface:SmbResourceRetrieve the time thisSmbResourcewas created. The value returned is suitable for constructing aDateobject (i.e. seconds since Epoch 1970). Times should be the same as those reported using the properties dialog of the Windows Explorer program. For Win95/98/Me this is actually the last write time. It is currently not possible to retrieve the create time from files on these systems.- Specified by:
createTimein interfaceSmbResource- Returns:
- The number of milliseconds since the 00:00:00 GMT, January 1,
1970 as a
longvalue - Throws:
SmbException
-
lastModified
public long lastModified() throws SmbExceptionDescription copied from interface:SmbResourceRetrieve the last time the file represented by thisSmbResourcewas modified. The value returned is suitable for constructing aDateobject (i.e. seconds since Epoch 1970). Times should be the same as those reported using the properties dialog of the Windows Explorer program.- Specified by:
lastModifiedin interfaceSmbResource- Returns:
- The number of milliseconds since the 00:00:00 GMT, January 1,
1970 as a
longvalue - Throws:
SmbException
-
lastAccess
public long lastAccess() throws SmbExceptionDescription copied from interface:SmbResourceRetrieve the last acces time of the file represented by thisSmbResource- Specified by:
lastAccessin interfaceSmbResource- Returns:
- The number of milliseconds since the 00:00:00 GMT, January 1,
1970 as a
longvalue - Throws:
SmbException
-
list
public String[] list() throws SmbException
List the contents of this SMB resource. The list returned by this method will be;- files and directories contained within this resource if the resource is a normal disk file directory,
- all available NetBIOS workgroups or domains if this resource is
the top level URL
smb://, - all servers registered as members of a NetBIOS workgroup if this
resource refers to a workgroup in a
smb://workgroup/URL, - all browseable shares of a server including printers, IPC
services, or disk volumes if this resource is a server URL in the form
smb://server/, - or
nullif the resource cannot be resolved.
- Returns:
- A
String[]array of files and directories, workgroups, servers, or shares depending on the context of the resource URL - Throws:
SmbException
-
list
public String[] list(SmbFilenameFilter filter) throws SmbException
List the contents of this SMB resource. The list returned will be identical to the list returned by the parameterlesslist()method minus filenames filtered by the specified filter.- Parameters:
filter- a filename filter to exclude filenames from the results- Returns:
String[]array of matching files and directories, workgroups, servers, or shares depending on the context of the resource URL- Throws:
SmbException- # @return An array of filenames
-
listFiles
public SmbFile[] listFiles() throws SmbException
List the contents of this SMB resource as an array ofSmbResourceobjects. This method is much more efficient than the regularlistmethod when querying attributes of each file in the result set.The list of
SmbResources returned by this method will be;- files and directories contained within this resource if the resource is a normal disk file directory,
- all available NetBIOS workgroups or domains if this resource is
the top level URL
smb://, - all servers registered as members of a NetBIOS workgroup if this
resource refers to a workgroup in a
smb://workgroup/URL, - all browseable shares of a server including printers, IPC
services, or disk volumes if this resource is a server URL in the form
smb://server/, - or
nullif the resource cannot be resolved.
- Returns:
- An array of
SmbResourceobjects representing file and directories, workgroups, servers, or shares depending on the context of the resource URL - Throws:
SmbException
-
listFiles
public SmbFile[] listFiles(String wildcard) throws SmbException
The CIFS protocol provides for DOS "wildcards" to be used as a performance enhancement. The client does not have to filter the names and the server does not have to return all directory entries.The wildcard expression may consist of two special meta characters in addition to the normal filename characters. The '*' character matches any number of characters in part of a name. If the expression begins with one or more '?'s then exactly that many characters will be matched whereas if it ends with '?'s it will match that many characters or less.
Wildcard expressions will not filter workgroup names or server names.
If strict resource lifecycle is used, make sure you close the individual files after use.winnt> ls c?o* clock.avi -rw-- 82944 Mon Oct 14 1996 1:38 AM Cookies drw-- 0 Fri Nov 13 1998 9:42 PM 2 items in 5ms
- Parameters:
wildcard- a wildcard expression- Returns:
- An array of
SmbResourceobjects representing file and directories, workgroups, servers, or shares depending on the context of the resource URL - Throws:
SmbException
-
listFiles
public SmbFile[] listFiles(SmbFilenameFilter filter) throws SmbException
List the contents of this SMB resource. The list returned will be identical to the list returned by the parameterlesslistFiles()method minus files filtered by the specified filename filter. If strict resource lifecycle is used, make sure you close the individual files after use.- Parameters:
filter- a filter to exclude files from the results- Returns:
- An array of SmbResource objects
- Throws:
SmbException
-
listFiles
public SmbFile[] listFiles(SmbFileFilter filter) throws SmbException
List the contents of this SMB resource. The list returned will be identical to the list returned by the parameterlesslistFiles()method minus filenames filtered by the specified filter. If strict resource lifecycle is used, make sure you close the individual files after use.- Parameters:
filter- a file filter to exclude files from the results- Returns:
- An array of SmbResource objects
- Throws:
SmbException
-
children
public CloseableIterator<SmbResource> children() throws CIFSException
Description copied from interface:SmbResourceFetch all children- Specified by:
childrenin interfaceSmbResource- Returns:
- an iterator over the child resources
- Throws:
CIFSException
-
children
public CloseableIterator<SmbResource> children(String wildcard) throws CIFSException
Description copied from interface:SmbResourceFetch children matching pattern, server-side filteringThe wildcard expression may consist of two special meta characters in addition to the normal filename characters. The '*' character matches any number of characters in part of a name. If the expression begins with one or more '?'s then exactly that many characters will be matched whereas if it ends with '?'s it will match that many characters or less.
Wildcard expressions will not filter workgroup names or server names.
- Specified by:
childrenin interfaceSmbResource- Returns:
- an iterator over the child resources
- Throws:
CIFSException
-
children
public CloseableIterator<SmbResource> children(ResourceNameFilter filter) throws CIFSException
- Specified by:
childrenin interfaceSmbResource- Parameters:
filter- filter acting on file names- Returns:
- an iterator over the child resources
- Throws:
CIFSException- See Also:
for a more efficient way to do this when a pattern on the filename is sufficient for filtering
-
children
public CloseableIterator<SmbResource> children(ResourceFilter filter) throws CIFSException
- Specified by:
childrenin interfaceSmbResource- Parameters:
filter- filter acting on SmbResource instances- Returns:
- an iterator over the child resources
- Throws:
CIFSException- See Also:
for a more efficient way to do this when a pattern on the filename is sufficient for filtering
-
renameTo
public void renameTo(SmbResource d) throws SmbException
Description copied from interface:SmbResourceChanges the name of the file thisSmbResourcerepresents to the name designated by theSmbResourceargument.
Remember:SmbResources are immutable and therefore the path associated with thisSmbResourceobject will not change). To access the renamed file it is necessary to construct a new SmbResource.- Specified by:
renameToin interfaceSmbResource- Parameters:
d- AnSmbResourcethat represents the new pathname- Throws:
SmbException
-
renameTo
public void renameTo(SmbResource d, boolean replace) throws SmbException
Description copied from interface:SmbResourceChanges the name of the file thisSmbResourcerepresents to the name designated by theSmbResourceargument.
Remember:SmbResources are immutable and therefore the path associated with thisSmbResourceobject will not change). To access the renamed file it is necessary to construct a new SmbResource.- Specified by:
renameToin interfaceSmbResource- Parameters:
d- AnSmbResourcethat represents the new pathnamereplace- Whether an existing destination file should be replaced (only supported with SMB2)- Throws:
SmbException
-
copyTo
public void copyTo(SmbResource d) throws SmbException
Description copied from interface:SmbResourceThis method will copy the file or directory represented by this SmbResource and it's sub-contents to the location specified by the dest parameter. This file and the destination file do not need to be on the same host. This operation does not copy extended file attributes such as ACLs but it does copy regular attributes as well as create and last write times. This method is almost twice as efficient as manually copying as it employs an additional write thread to read and write data concurrently.
It is not possible (nor meaningful) to copy entire workgroups or servers.- Specified by:
copyToin interfaceSmbResource- Parameters:
d- the destination file or directory- Throws:
SmbException
-
delete
public void delete() throws SmbExceptionDescription copied from interface:SmbResourceThis method will delete the file or directory specified by thisSmbResource. If the target is a directory, the contents of the directory will be deleted as well. If a file within the directory or it's sub-directories is marked read-only, the read-only status will be removed and the file will be deleted. If the file has been opened before, it will be closed.- Specified by:
deletein interfaceSmbResource- Throws:
SmbException
-
length
public long length() throws SmbExceptionDescription copied from interface:SmbResourceReturns the length of this SmbResource in bytes. If this object is a TYPE_SHARE the total capacity of the disk shared in bytes is returned. If this object is a directory or a type other than TYPE_SHARE, 0L is returned.- Specified by:
lengthin interfaceSmbResource- Returns:
- The length of the file in bytes or 0 if this
SmbResourceis not a file. - Throws:
SmbException
-
getDiskFreeSpace
public long getDiskFreeSpace() throws SmbExceptionDescription copied from interface:SmbResourceThis method returns the free disk space in bytes of the drive this share represents or the drive on which the directory or file resides. Objects other than TYPE_SHARE or TYPE_FILESYSTEM will result in 0L being returned.- Specified by:
getDiskFreeSpacein interfaceSmbResource- Returns:
- the free disk space in bytes of the drive on which this file or directory resides
- Throws:
SmbException
-
mkdir
public void mkdir() throws SmbExceptionDescription copied from interface:SmbResourceCreates a directory with the path specified by thisSmbResource. For this method to be successful, the target must not already exist. This method will fail when used withsmb://,smb://workgroup/,smb://server/, orsmb://server/share/URLs because workgroups, servers, and shares cannot be dynamically created (although in the future it may be possible to create shares).- Specified by:
mkdirin interfaceSmbResource- Throws:
SmbException
-
mkdirs
public void mkdirs() throws SmbExceptionDescription copied from interface:SmbResourceCreates a directory with the path specified by this SmbResource and any parent directories that do not exist. This method will fail when used withsmb://,smb://workgroup/,smb://server/, orsmb://server/share/URLs because workgroups, servers, and shares cannot be dynamically created (although in the future it may be possible to create shares).- Specified by:
mkdirsin interfaceSmbResource- Throws:
SmbException
-
withOpen
protected <T extends ServerMessageBlock2Response> T withOpen(jcifs.smb.SmbTreeHandleImpl th, ServerMessageBlock2Request<T> first, ServerMessageBlock2Request<?>... others) throws CIFSException
- Throws:
CIFSException
-
withOpen
protected <T extends ServerMessageBlock2Response> T withOpen(jcifs.smb.SmbTreeHandleImpl th, int createDisposition, int desiredAccess, int shareAccess, ServerMessageBlock2Request<T> first, ServerMessageBlock2Request<?>... others) throws CIFSException
- Throws:
CIFSException
-
withOpen
protected <T extends ServerMessageBlock2Response> T withOpen(jcifs.smb.SmbTreeHandleImpl th, int createDisposition, int createOptions, int fileAttributes, int desiredAccess, int shareAccess, ServerMessageBlock2Request<T> first, ServerMessageBlock2Request<?>... others) throws CIFSException
- Throws:
CIFSException
-
createNewFile
public void createNewFile() throws SmbExceptionDescription copied from interface:SmbResourceCreate a new file but fail if it already exists. The check for existence of the file and it's creation are an atomic operation with respect to other filesystem activities.- Specified by:
createNewFilein interfaceSmbResource- Throws:
SmbException
-
setFileTimes
public void setFileTimes(long createTime, long lastLastModified, long lastLastAccess) throws SmbExceptionDescription copied from interface:SmbResourceSet the create, last modified and last access time of the file. The time is specified as milliseconds from Jan 1, 1970 which is the same as that which is returned by the createTime(), lastModified(), lastAccess() methods.
This method does not apply to workgroups, servers, or shares.- Specified by:
setFileTimesin interfaceSmbResource- Parameters:
createTime- the create time as milliseconds since Jan 1, 1970lastLastModified- the last modified time as milliseconds since Jan 1, 1970lastLastAccess- the last access time as milliseconds since Jan 1, 1970- Throws:
SmbUnsupportedOperationException- if CAP_NT_SMBS is unavailableSmbException- See Also:
SmbResource.setCreateTime(long),SmbResource.setLastAccess(long),SmbResource.setLastModified(long)
-
setCreateTime
public void setCreateTime(long time) throws SmbExceptionDescription copied from interface:SmbResourceSet the create time of the file. The time is specified as milliseconds from Jan 1, 1970 which is the same as that which is returned by the createTime() method.
This method does not apply to workgroups, servers, or shares.- Specified by:
setCreateTimein interfaceSmbResource- Parameters:
time- the create time as milliseconds since Jan 1, 1970- Throws:
SmbUnsupportedOperationException- if CAP_NT_SMBS is unavailableSmbException
-
setLastModified
public void setLastModified(long time) throws SmbExceptionDescription copied from interface:SmbResourceSet the last modified time of the file. The time is specified as milliseconds from Jan 1, 1970 which is the same as that which is returned by the lastModified() method.
This method does not apply to workgroups, servers, or shares.- Specified by:
setLastModifiedin interfaceSmbResource- Parameters:
time- the last modified time as milliseconds since Jan 1, 1970- Throws:
SmbException
-
setLastAccess
public void setLastAccess(long time) throws SmbExceptionDescription copied from interface:SmbResourceSet the last access time of the file. The time is specified as milliseconds from Jan 1, 1970 which is the same as that which is returned by the lastAccess() method.
This method does not apply to workgroups, servers, or shares.- Specified by:
setLastAccessin interfaceSmbResource- Parameters:
time- the last access time as milliseconds since Jan 1, 1970- Throws:
SmbUnsupportedOperationException- if CAP_NT_SMBS is unavailableSmbException
-
getAttributes
public int getAttributes() throws SmbExceptionDescription copied from interface:SmbResourceReturn the attributes of this file. Attributes are represented as a bitset that must be masked with ATTR_* constants to determine if they are set or unset. The value returned is suitable for use with the setAttributes() method.- Specified by:
getAttributesin interfaceSmbResource- Returns:
- the ATTR_* attributes associated with this file
- Throws:
SmbException
-
setAttributes
public void setAttributes(int attrs) throws SmbExceptionDescription copied from interface:SmbResourceSet the attributes of this file. Attributes are composed into a bitset by bitwise ORing the ATTR_* constants. Setting the value returned by getAttributes will result in both files having the same attributes.- Specified by:
setAttributesin interfaceSmbResource- Parameters:
attrs- attribute flags- Throws:
SmbException
-
setReadOnly
public void setReadOnly() throws SmbExceptionDescription copied from interface:SmbResourceMake this file read-only. This is shorthand for setAttributes( getAttributes() | ATTR_READ_ONLY ).- Specified by:
setReadOnlyin interfaceSmbResource- Throws:
SmbException
-
setReadWrite
public void setReadWrite() throws SmbExceptionDescription copied from interface:SmbResourceTurn off the read-only attribute of this file. This is shorthand for setAttributes( getAttributes() & ~ATTR_READONLY ).- Specified by:
setReadWritein interfaceSmbResource- Throws:
SmbException
-
toURL
@Deprecated public URL toURL()
Deprecated.Use getURL() insteadReturns aURLfor thisSmbFile. TheURLmay be used as any otherURLmight to access an SMB resource. Currently only retrieving data and information is supported (i.e. no doOutput).- Returns:
- A new
for thisURLSmbFile
-
hashCode
public int hashCode()
Computes a hashCode for this file based on the URL string and IP address if the server. The hashing function uses the hashcode of the server address, the canonical representation of the URL, and does not compare authentication information. In essence, twoSmbFileobjects that refer to the same file should generate the same hashcode provided it is possible to make such a determination.
-
equals
public boolean equals(Object obj)
Tests to see if twoSmbFileobjects are equal. Two SmbFile objects are equal when they reference the same SMB resource. More specifically, twoSmbFileobjects are equals if their server IP addresses are equal and the canonicalized representation of their URLs, minus authentication parameters, are case insensitively and lexographically equal.
For example, assuming the serverangusresolves to the192.168.1.15IP address, the below URLs would result inSmbFiles that are equal.smb://192.168.1.15/share/DIR/foo.txt smb://angus/share/data/../dir/foo.txt
-
toString
public String toString()
Returns the string representation of this SmbFile object. This will be the same as the URL used to construct thisSmbFile. This method will return the same value asgetPath.- Overrides:
toStringin classURLConnection- Returns:
- The original URL representation of this SMB resource
-
getContentLength
@Deprecated public int getContentLength()
Deprecated.This URLConnection method just returns the result of length().- Overrides:
getContentLengthin classURLConnection- Returns:
- the length of this file or 0 if it refers to a directory
-
getContentLengthLong
public long getContentLengthLong()
- Overrides:
getContentLengthLongin classURLConnection- See Also:
URLConnection.getContentLengthLong()
-
getDate
public long getDate()
This URLConnection method just returns the result of lastModified.- Overrides:
getDatein classURLConnection- Returns:
- the last modified data as milliseconds since Jan 1, 1970
-
getLastModified
public long getLastModified()
This URLConnection method just returns the result of lastModified.- Overrides:
getLastModifiedin classURLConnection- Returns:
- the last modified data as milliseconds since Jan 1, 1970
-
getInputStream
public InputStream getInputStream() throws IOException
This URLConnection method just returns a new SmbFileInputStream created with this file.- Overrides:
getInputStreamin classURLConnection- Throws:
IOException- thrown by SmbFileInputStream constructor
-
openInputStream
public SmbFileInputStream openInputStream() throws SmbException
Description copied from interface:SmbResourceOpens an input stream reading the file (read only, sharable)- Specified by:
openInputStreamin interfaceSmbResource- Returns:
- input stream, needs to be closed when finished
- Throws:
SmbException
-
openInputStream
public SmbFileInputStream openInputStream(int sharing) throws SmbException
Description copied from interface:SmbResourceOpens an input stream reading the file (read only)- Specified by:
openInputStreamin interfaceSmbResource- Parameters:
sharing- flags indicating for which operations others may open the file (FILE_SHARING_*)- Returns:
- input stream, needs to be closed when finished
- Throws:
SmbException
-
openInputStream
public SmbFileInputStream openInputStream(int flags, int access, int sharing) throws SmbException
Description copied from interface:SmbResourceOpens an input stream reading the file (read only)- Specified by:
openInputStreamin interfaceSmbResource- Parameters:
flags- open flagsaccess- desired access flagssharing- flags indicating for which operations others may open the file (FILE_SHARING_*)- Returns:
- input stream, needs to be closed when finished
- Throws:
SmbException
-
getOutputStream
public OutputStream getOutputStream() throws IOException
- Overrides:
getOutputStreamin classURLConnection- Throws:
IOException
-
openOutputStream
public SmbFileOutputStream openOutputStream() throws SmbException
Description copied from interface:SmbResourceOpens an output stream writing to the file (truncating, write only, sharable)- Specified by:
openOutputStreamin interfaceSmbResource- Returns:
- output stream, needs to be closed when finished
- Throws:
SmbException
-
openOutputStream
public SmbFileOutputStream openOutputStream(boolean append) throws SmbException
Description copied from interface:SmbResourceOpens an output stream writing to the file (write only, read sharable)- Specified by:
openOutputStreamin interfaceSmbResource- Parameters:
append- whether to append to or truncate the input- Returns:
- output stream, needs to be closed when finished
- Throws:
SmbException
-
openOutputStream
public SmbFileOutputStream openOutputStream(boolean append, int sharing) throws SmbException
Description copied from interface:SmbResourceOpens an output stream writing to the file (write only, exclusive write access)- Specified by:
openOutputStreamin interfaceSmbResource- Parameters:
append- whether to append to or truncate the inputsharing- flags indicating for which operations others may open the file (FILE_SHARING_*)- Returns:
- output stream, needs to be closed when finished
- Throws:
SmbException
-
openOutputStream
public SmbFileOutputStream openOutputStream(boolean append, int openFlags, int access, int sharing) throws SmbException
Description copied from interface:SmbResourceOpens an output stream writing to the file (write only, exclusive write access)- Specified by:
openOutputStreamin interfaceSmbResource- Parameters:
append- whether to append to or truncate the inputopenFlags- flags for open operationaccess- desired file access flagssharing- flags indicating for which operations others may open the file- Returns:
- output stream, needs to be closed when finished
- Throws:
SmbException
-
openRandomAccess
public SmbRandomAccessFile openRandomAccess(String mode) throws SmbException
Description copied from interface:SmbResourceOpens the file for random access- Specified by:
openRandomAccessin interfaceSmbResource- Parameters:
mode- access mode (r|rw)- Returns:
- random access file, needs to be closed when finished
- Throws:
SmbException
-
openRandomAccess
public SmbRandomAccessFile openRandomAccess(String mode, int sharing) throws SmbException
Description copied from interface:SmbResourceOpens the file for random access- Specified by:
openRandomAccessin interfaceSmbResource- Parameters:
mode- access mode (r|rw)sharing- flags indicating for which operations others may concurrently open the file- Returns:
- random access file, needs to be closed when finished
- Throws:
SmbException
-
fileIndex
public long fileIndex() throws SmbExceptionDescription copied from interface:SmbResourceGet the file index- Specified by:
fileIndexin interfaceSmbResource- Returns:
- server side file index, 0 if unavailable
- Throws:
SmbException
-
getSecurity
public ACE[] getSecurity() throws IOException
Description copied from interface:SmbResourceReturn an array of Access Control Entry (ACE) objects representing the security descriptor associated with this file or directory.Initially, the SIDs within each ACE will not be resolved however when getType(), getDomainName(), getAccountName(), or toString() is called, the names will attempt to be resolved. If the names cannot be resolved (e.g. due to temporary network failure), the said methods will return default values (usually S-X-Y-Z strings of fragments of).
Alternatively getSecurity(true) may be used to resolve all SIDs together and detect network failures.
- Specified by:
getSecurityin interfaceSmbResource- Returns:
- array of ACEs
- Throws:
IOException
-
getSecurity
public ACE[] getSecurity(boolean resolveSids) throws IOException
Description copied from interface:SmbResourceReturn an array of Access Control Entry (ACE) objects representing the security descriptor associated with this file or directory. If no DACL is present, null is returned. If the DACL is empty, an array with 0 elements is returned.- Specified by:
getSecurityin interfaceSmbResource- Parameters:
resolveSids- Attempt to resolve the SIDs within each ACE form their numeric representation to their corresponding account names.- Returns:
- array of ACEs
- Throws:
IOException
-
getOwnerUser
public SID getOwnerUser() throws IOException
Description copied from interface:SmbResourceReturn the resolved owner user SID for this file or directory- Specified by:
getOwnerUserin interfaceSmbResource- Returns:
- the owner user SID,
nullif not present - Throws:
IOException
-
getOwnerUser
public SID getOwnerUser(boolean resolve) throws IOException
Description copied from interface:SmbResourceReturn the owner user SID for this file or directory- Specified by:
getOwnerUserin interfaceSmbResource- Parameters:
resolve- whether to resolve the user name- Returns:
- the owner user SID,
nullif not present - Throws:
IOException
-
getOwnerGroup
public SID getOwnerGroup() throws IOException
Description copied from interface:SmbResourceReturn the resolved owner group SID for this file or directory- Specified by:
getOwnerGroupin interfaceSmbResource- Returns:
- the owner group SID,
nullif not present - Throws:
IOException
-
getOwnerGroup
public SID getOwnerGroup(boolean resolve) throws IOException
Description copied from interface:SmbResourceReturn the owner group SID for this file or directory- Specified by:
getOwnerGroupin interfaceSmbResource- Parameters:
resolve- whether to resolve the group name- Returns:
- the owner group SID,
nullif not present - Throws:
IOException
-
getShareSecurity
public ACE[] getShareSecurity(boolean resolveSids) throws IOException
Description copied from interface:SmbResourceReturn an array of Access Control Entry (ACE) objects representing the share permissions on the share exporting this file or directory. If no DACL is present, null is returned. If the DACL is empty, an array with 0 elements is returned.Note that this is different from calling getSecurity on a share. There are actually two different ACLs for shares - the ACL on the share and the ACL on the folder being shared. Go to Computer Management > System Tools > Shared Folders > Shares and look at the Properties for a share. You will see two tabs - one for "Share Permissions" and another for "Security". These correspond to the ACLs returned by getShareSecurity and getSecurity respectively.
- Specified by:
getShareSecurityin interfaceSmbResource- Parameters:
resolveSids- Attempt to resolve the SIDs within each ACE form their numeric representation to their corresponding account names.- Returns:
- array of ACEs
- Throws:
IOException
-
-