public class SmbFile extends URLConnection implements SmbResource, SmbConstants
SmbFile
may also refer to servers and workgroups. If the resource is a file or
directory the methods of SmbFile
follow the behavior of
the well known File
class. 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.txt
foo.txt
in the share
public
on the server storage15
. 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 tmp on the server
angus as user miallen who's password is
mypass .
|
smb://Administrator:P%40ss@msmith1/c/WINDOWS/Desktop/foo.txt |
A relativly sophisticated example that references a file
msmith1 's desktop as user Administrator . 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 delete a server) however
as you might expect the list method will list the available
shares on this server.
|
smb://myworkgroup/ |
This syntactically is identical to the above example. However if
myworkgroup happends to be a workgroup(which is indeed
suggested by the name) the list method will return
a list of servers that have registered themselves as members of
myworkgroup .
|
smb:// |
Just as smb://server/ lists shares and
smb://workgroup/ lists servers, the smb://
URL lists all available workgroups on a netbios LAN. Again,
in this context many methods are not valid and return default
values(e.g. isHidden will always return false).
|
smb://angus.foo.net/d/jcifs/pipes.doc |
The 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.txt |
A prototypical example that uses all the fields. |
smb://myworkgroup/angus/ <-- ILLEGAL |
Despite the hierarchial relationship between workgroups, servers, and filesystems this example is not valid. |
smb://server/share/path/to/dir <-- ILLEGAL |
URLs that represent workgroups, servers, shares, or directories require a trailing slash '/'. |
smb://MYGROUP/?SERVER=192.168.10.15 |
SMB URLs support some query string parameters. In this example
the SERVER parameter is used to override the
server name service lookup to contact the server 192.168.10.15
(presumably known to be a master
browser) for the server list in workgroup MYGROUP .
|
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.File
usage; 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 contructor
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/zag
|
smb://host/share2/zig/zag
|
smb://host/share/foo/bar/
|
../zip/
|
smb://host/share/foo/zip/
|
smb://host/share/zig/zag
|
smb://foo/bar/
|
smb://foo/bar/
|
smb://host/share/foo/
|
../.././.././../foo/
|
smb://host/foo/
|
smb://host/share/zig/zag
|
/
|
smb://host/
|
smb://server/
|
../
|
smb://server/
|
smb://
|
myworkgroup/
|
smb://myworkgroup/
|
smb://myworkgroup/
|
angus/
|
smb://myworkgroup/angus/ <-- ILLEGAL |
Instances of the SmbFile
class are immutable; that is,
once created, the abstract pathname represented by an SmbFile object
will never change.
File
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 and Description |
---|
SmbFile(SmbResource context,
String name)
Constructs an SmbFile representing a resource on an SMB network such
as a file or directory.
|
SmbFile(String url)
Deprecated.
|
SmbFile(String url,
CIFSContext tc)
Construct from string URL
|
SmbFile(URL url)
Deprecated.
|
SmbFile(URL url,
CIFSContext tc)
Construct from URL
|
Modifier and Type | Method and Description |
---|---|
boolean |
canRead()
Tests to see if the file this
SmbResource represents can be
read. |
boolean |
canWrite()
Tests to see if the file this
SmbResource represents
exists and is not marked read-only. |
CloseableIterator<SmbResource> |
children()
Fetch all children
|
CloseableIterator<SmbResource> |
children(ResourceFilter filter) |
CloseableIterator<SmbResource> |
children(ResourceNameFilter filter) |
CloseableIterator<SmbResource> |
children(String wildcard)
Fetch children matching pattern, server-side filtering
|
void |
close()
Close/release the file
This releases all resources that this file holds.
|
void |
connect() |
void |
copyTo(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.
|
void |
createNewFile()
Create a new file but fail if it already exists.
|
long |
createTime()
Retrieve the time this
SmbResource was created. |
void |
delete()
This method will delete the file or directory specified by this
SmbResource . |
boolean |
equals(Object obj)
Tests to see if two
SmbFile objects are equal. |
boolean |
exists()
Tests to see if the SMB resource exists.
|
long |
fileIndex()
Get the file index
|
int |
getAttributes()
Return the attributes of this file.
|
String |
getCanonicalPath()
Returns the full URL of this SMB resource with '.' and '..' components
factored out.
|
String |
getCanonicalUncPath()
Retuns the Windows UNC style path with backslashs intead of forward slashes.
|
int |
getContentLength()
Deprecated.
|
long |
getContentLengthLong() |
CIFSContext |
getContext()
The context this file was opened with
|
long |
getDate()
This URLConnection method just returns the result of lastModified.
|
String |
getDfsPath()
If the path of this
SmbFile falls within a DFS volume,
this method will return the referral path to which it maps. |
long |
getDiskFreeSpace()
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.
|
InputStream |
getInputStream()
This URLConnection method just returns a new SmbFileInputStream created with this file.
|
long |
getLastModified()
This URLConnection method just returns the result of lastModified.
|
SmbResourceLocator |
getLocator()
Gets the file locator for this file
The file locator provides details about
|
String |
getName()
Returns the last component of the target URL.
|
OutputStream |
getOutputStream() |
SID |
getOwnerGroup()
Return the resolved owner group SID for this file or directory
|
SID |
getOwnerGroup(boolean resolve)
Return the owner group SID for this file or directory
|
SID |
getOwnerUser()
Return the resolved owner user SID for this file or directory
|
SID |
getOwnerUser(boolean resolve)
Return the owner user SID for this file or directory
|
String |
getParent()
Everything but the last component of the URL representing this SMB
resource is effectivly it's parent.
|
String |
getPath()
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.
|
String |
getServer()
Retrieve the hostname of the server for this SMB resource.
|
String |
getServerWithDfs()
Retrieve the hostname of the server for this SMB resource.
|
String |
getShare()
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.
|
CIFSContext |
getTransportContext()
Deprecated.
|
SmbTreeHandle |
getTreeHandle() |
int |
getType()
Returns type of of object this SmbResource represents.
|
String |
getUncPath() |
int |
hashCode()
Computes a hashCode for this file based on the URL string and IP
address if the server.
|
boolean |
isDirectory()
Tests to see if the file this
SmbResource represents is a directory. |
boolean |
isFile()
Tests to see if the file this
SmbResource represents is not a directory. |
boolean |
isHidden()
Tests to see if the file this SmbResource represents is marked as
hidden.
|
long |
lastAccess()
Retrieve the last acces time of the file represented by this
SmbResource |
long |
lastModified()
Retrieve the last time the file represented by this
SmbResource was modified. |
long |
length()
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 of
SmbResource objects. |
SmbFile[] |
listFiles(SmbFileFilter filter)
List the contents of this SMB resource.
|
SmbFile[] |
listFiles(SmbFilenameFilter filter)
List the contents of this SMB resource.
|
SmbFile[] |
listFiles(String wildcard)
The CIFS protocol provides for DOS "wildcards" to be used as
a performance enhancement.
|
void |
mkdir()
Creates a directory with the path specified by this
SmbResource . |
void |
mkdirs()
Creates a directory with the path specified by this SmbResource
and any parent directories that do not exist.
|
SmbFileInputStream |
openInputStream()
Opens an input stream reading the file (read only, sharable)
|
SmbFileInputStream |
openInputStream(int sharing)
Opens an input stream reading the file (read only)
|
SmbFileInputStream |
openInputStream(int flags,
int access,
int sharing)
Opens an input stream reading the file (read only)
|
SmbFileOutputStream |
openOutputStream()
Opens an output stream writing to the file (truncating, write only, sharable)
|
SmbFileOutputStream |
openOutputStream(boolean append)
Opens an output stream writing to the file (write only, read sharable)
|
SmbFileOutputStream |
openOutputStream(boolean append,
int sharing)
Opens an output stream writing to the file (write only, exclusive write access)
|
SmbFileOutputStream |
openOutputStream(boolean append,
int openFlags,
int access,
int sharing)
Opens an output stream writing to the file (write only, exclusive write access)
|
SmbRandomAccessFile |
openRandomAccess(String mode)
Opens the file for random access
|
SmbRandomAccessFile |
openRandomAccess(String mode,
int sharing)
Opens the file for random access
|
void |
renameTo(SmbResource d)
Changes the name of the file this
SmbResource represents to the name
designated by the SmbResource argument. |
void |
renameTo(SmbResource d,
boolean replace)
Changes the name of the file this
SmbResource represents to the name
designated by the SmbResource argument. |
SmbResource |
resolve(String name)
Fetch a child resource
|
void |
setAttributes(int attrs)
Set the attributes of this file.
|
void |
setCreateTime(long time)
Set the create time of the file.
|
void |
setLastAccess(long time)
Set the last accesss time of the file.
|
void |
setLastModified(long time)
Set the last modified time of the file.
|
void |
setReadOnly()
Make this file read-only.
|
void |
setReadWrite()
Turn off the read-only attribute of this file.
|
String |
toString()
Returns the string representation of this SmbFile object.
|
URL |
toURL()
Deprecated.
Use getURL() instead
|
SmbWatchHandle |
watch(int filter,
boolean recursive)
Creates a directory watch
The server will notify the client when there are changes to the directories contents
|
addRequestProperty, getAllowUserInteraction, getConnectTimeout, getContent, getContent, getContentEncoding, getContentType, getDefaultAllowUserInteraction, getDefaultRequestProperty, 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, setDoInput, setDoOutput, setFileNameMap, setIfModifiedSince, setReadTimeout, setRequestProperty, setUseCaches
@Deprecated public SmbFile(String url) throws MalformedURLException
url
- A URL stringMalformedURLException
- If the parent
and child
parameters
do not follow the prescribed syntax@Deprecated public SmbFile(URL url)
url
- The URL of the target resourcepublic SmbFile(SmbResource context, String name) throws MalformedURLException, UnknownHostException
parent SmbFile
. See the description above for examples
of using the second name
parameter.context
- A base SmbFile
name
- A path string relative to the parent
paremeterMalformedURLException
- If the parent
and child
parameters
do not follow the prescribed syntaxUnknownHostException
- If the server or workgroup of the context file cannot be determinedpublic SmbFile(String url, CIFSContext tc) throws MalformedURLException
url
- tc
- context to useMalformedURLException
public SmbFile(URL url, CIFSContext tc)
url
- tc
- context to usepublic void connect() throws IOException
connect
in class URLConnection
IOException
URLConnection.connect()
public SmbTreeHandle getTreeHandle() throws CIFSException
CIFSException
public void close()
close
in interface AutoCloseable
close
in interface SmbResource
AutoCloseable.close()
@Deprecated public CIFSContext getTransportContext()
public CIFSContext getContext()
SmbResource
getContext
in interface SmbResource
public SmbResourceLocator getLocator()
SmbResource
getLocator
in interface SmbResource
public SmbResource resolve(String name) throws CIFSException
SmbResource
resolve
in interface SmbResource
CIFSException
public String getUncPath()
public boolean exists() throws SmbException
SmbResource
SmbResource
refers to the root
smb://
resource true
is always returned. If
this SmbResource
is a traditional file or directory, it will
be queried for on the specified server as expected.exists
in interface SmbResource
true
if the resource exists or is alive or
false
otherwiseSmbException
public int getType() throws SmbException
SmbResource
getType
in interface SmbResource
SmbException
public String getName()
SmbResource
SmbResource
or in the case of URLs that only specify a server
or workgroup, the server or workgroup will be returned. The name of
the root URL smb://
is also smb://
. 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.getName
in interface SmbResource
smb://
if the resource is smb://
itself.public String getParent()
smb://
does not have a parent. In this case smb://
is returned.smb://
if the resource refers to the root of the URL
hierarchy which incedentally is also smb://
.public String getPath()
SmbFile
constructed with the result of this method will
result in an SmbFile
that is equal to the original.public String getCanonicalUncPath()
public String getDfsPath() throws SmbException
SmbFile
falls within a DFS volume,
this method will return the referral path to which it maps. Otherwise
null
is returned.SmbException
public String getCanonicalPath()
SmbFile
constructed with the result of
this method will result in an SmbFile
that is equal to
the original.public String getShare()
smb://
, smb://workgroup/
,
and smb://server/
URLs which do not specify a share,
null
will be returned.null
if there is no sharepublic String getServerWithDfs()
public String getServer()
SmbFile
references a workgroup, the name of the workgroup
is returned. If this SmbFile
refers to the root of this
SMB network hierarchy, null
is returned.null
if this
SmbFile
refers to the root smb://
resource.public SmbWatchHandle watch(int filter, boolean recursive) throws CIFSException
SmbResource
watch
in interface SmbResource
filter
- see constants in FileNotifyInformation
recursive
- whether to also watch subdirectoriesCIFSException
public boolean canRead() throws SmbException
SmbResource
SmbResource
represents can be
read. Because any file, directory, or other resource can be read if it
exists, this method simply calls the exists
method.canRead
in interface SmbResource
true
if the file is read-onlySmbException
public boolean canWrite() throws SmbException
SmbResource
SmbResource
represents
exists and is not marked read-only. By default, resources are
considered to be read-only and therefore for smb://
,
smb://workgroup/
, and smb://server/
resources
will be read-only.canWrite
in interface SmbResource
true
if the resource exists is not marked
read-onlySmbException
public boolean isDirectory() throws SmbException
SmbResource
SmbResource
represents is a directory.isDirectory
in interface SmbResource
true
if this SmbResource
is a directorySmbException
public boolean isFile() throws SmbException
SmbResource
SmbResource
represents is not a directory.isFile
in interface SmbResource
true
if this SmbResource
is not a directorySmbException
public boolean isHidden() throws SmbException
SmbResource
IPC$
or C$
.isHidden
in interface SmbResource
true
if the SmbResource
is marked as being hiddenSmbException
public long createTime() throws SmbException
SmbResource
SmbResource
was created. The value
returned is suitable for constructing a Date
object
(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.createTime
in interface SmbResource
long
valueSmbException
public long lastModified() throws SmbException
SmbResource
SmbResource
was modified. The value returned is suitable for
constructing a Date
object (i.e. seconds since Epoch
1970). Times should be the same as those reported using the properties
dialog of the Windows Explorer program.lastModified
in interface SmbResource
long
valueSmbException
public long lastAccess() throws SmbException
SmbResource
SmbResource
lastAccess
in interface SmbResource
long
valueSmbException
public String[] list() throws SmbException
smb://
,
smb://workgroup/
URL,
smb://server/
,
null
if the resource cannot be resolved.
String[]
array of files and directories,
workgroups, servers, or shares depending on the context of the
resource URLSmbException
public String[] list(SmbFilenameFilter filter) throws SmbException
list()
method minus filenames filtered by the specified filter.filter
- a filename filter to exclude filenames from the resultsString[]
array of matching files and directories,
workgroups, servers, or shares depending on the context of the
resource URLSmbException
- # @return An array of filenamespublic SmbFile[] listFiles() throws SmbException
SmbResource
objects. This method is much more efficient than
the regular list
method when querying attributes of each
file in the result set.
The list of SmbResource
s returned by this method will be;
smb://
,
smb://workgroup/
URL,
smb://server/
,
null
if the resource cannot be resolved.
SmbResource
objects representing file
and directories, workgroups, servers, or shares depending on the context
of the resource URLSmbException
public SmbFile[] listFiles(String wildcard) throws SmbException
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
wildcard
- a wildcard expressionSmbResource
objects representing file
and directories, workgroups, servers, or shares depending on the context
of the resource URLSmbException
public SmbFile[] listFiles(SmbFilenameFilter filter) throws SmbException
listFiles()
method minus files filtered by the specified filename filter.
If strict resource lifecycle is used, make sure you close the individual files after use.filter
- a filter to exclude files from the resultsSmbException
public SmbFile[] listFiles(SmbFileFilter filter) throws SmbException
listFiles()
method minus filenames filtered by the specified filter.
If strict resource lifecycle is used, make sure you close the individual files after use.filter
- a file filter to exclude files from the resultsSmbException
public CloseableIterator<SmbResource> children() throws CIFSException
SmbResource
children
in interface SmbResource
CIFSException
public CloseableIterator<SmbResource> children(String wildcard) throws CIFSException
SmbResource
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.
children
in interface SmbResource
CIFSException
public CloseableIterator<SmbResource> children(ResourceNameFilter filter) throws CIFSException
children
in interface SmbResource
filter
- filter acting on file namesCIFSException
for a more efficient way to do this when a pattern on the filename is
sufficient for filtering
public CloseableIterator<SmbResource> children(ResourceFilter filter) throws CIFSException
children
in interface SmbResource
filter
- filter acting on SmbResource instancesCIFSException
for a more efficient way to do this when a pattern on the filename is
sufficient for filtering
public void renameTo(SmbResource d) throws SmbException
SmbResource
SmbResource
represents to the name
designated by the SmbResource
argument.
SmbResource
s are immutible and therefore
the path associated with this SmbResource
object will not
change). To access the renamed file it is necessary to construct a
new SmbResource.renameTo
in interface SmbResource
d
- An SmbResource
that represents the new pathnameSmbException
public void renameTo(SmbResource d, boolean replace) throws SmbException
SmbResource
SmbResource
represents to the name
designated by the SmbResource
argument.
SmbResource
s are immutible and therefore
the path associated with this SmbResource
object will not
change). To access the renamed file it is necessary to construct a
new SmbResource.renameTo
in interface SmbResource
d
- An SmbResource
that represents the new pathnamereplace
- Whether an existing destination file should be replaced (only supported with SMB2)SmbException
public void copyTo(SmbResource d) throws SmbException
SmbResource
copyTo
in interface SmbResource
d
- the destination file or directorySmbException
public void delete() throws SmbException
SmbResource
SmbResource
. 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.delete
in interface SmbResource
SmbException
public long length() throws SmbException
SmbResource
length
in interface SmbResource
SmbResource
is not a file.SmbException
public long getDiskFreeSpace() throws SmbException
SmbResource
getDiskFreeSpace
in interface SmbResource
SmbException
public void mkdir() throws SmbException
SmbResource
SmbResource
. For this method to be successful, the target
must not already exist. This method will fail when
used with smb://
, smb://workgroup/
,
smb://server/
, or smb://server/share/
URLs
because workgroups, servers, and shares cannot be dynamically created
(although in the future it may be possible to create shares).mkdir
in interface SmbResource
SmbException
public void mkdirs() throws SmbException
SmbResource
smb://
, smb://workgroup/
,
smb://server/
, or smb://server/share/
URLs
because workgroups, servers, and shares cannot be dynamically created
(although in the future it may be possible to create shares).mkdirs
in interface SmbResource
SmbException
public void createNewFile() throws SmbException
SmbResource
createNewFile
in interface SmbResource
SmbException
public void setCreateTime(long time) throws SmbException
SmbResource
setCreateTime
in interface SmbResource
time
- the create time as milliseconds since Jan 1, 1970SmbUnsupportedOperationException
- if CAP_NT_SMBS is unavailableSmbException
public void setLastModified(long time) throws SmbException
SmbResource
setLastModified
in interface SmbResource
time
- the last modified time as milliseconds since Jan 1, 1970SmbException
public void setLastAccess(long time) throws SmbException
SmbResource
setLastAccess
in interface SmbResource
time
- the last access time as milliseconds since Jan 1, 1970SmbUnsupportedOperationException
- if CAP_NT_SMBS is unavailableSmbException
public int getAttributes() throws SmbException
SmbResource
getAttributes
in interface SmbResource
SmbException
public void setAttributes(int attrs) throws SmbException
SmbResource
setAttributes
in interface SmbResource
attrs
- attribute flagsSmbException
public void setReadOnly() throws SmbException
SmbResource
setReadOnly
in interface SmbResource
SmbException
public void setReadWrite() throws SmbException
SmbResource
setReadWrite
in interface SmbResource
SmbException
@Deprecated public URL toURL()
URL
for this SmbFile
. The
URL
may be used as any other URL
might to
access an SMB resource. Currently only retrieving data and information
is supported (i.e. no doOutput).URL
for this SmbFile
public int hashCode()
SmbFile
objects that refer to
the same file should generate the same hashcode provided it is possible
to make such a determination.public boolean equals(Object obj)
SmbFile
objects are equal. Two
SmbFile objects are equal when they reference the same SMB
resource. More specifically, two SmbFile
objects are
equals if their server IP addresses are equal and the canonicalized
representation of their URLs, minus authentication parameters, are
case insensitivly and lexographically equal.
angus
resolves to the
192.168.1.15
IP address, the below URLs would result in
SmbFile
s that are equal.
smb://192.168.1.15/share/DIR/foo.txt smb://angus/share/data/../dir/foo.txt
public String toString()
SmbFile
.
This method will return the same value
as getPath
.toString
in class URLConnection
@Deprecated public int getContentLength()
getContentLength
in class URLConnection
public long getContentLengthLong()
getContentLengthLong
in class URLConnection
URLConnection.getContentLengthLong()
public long getDate()
getDate
in class URLConnection
public long getLastModified()
getLastModified
in class URLConnection
public InputStream getInputStream() throws IOException
getInputStream
in class URLConnection
IOException
- thrown by SmbFileInputStream constructorpublic SmbFileInputStream openInputStream() throws SmbException
SmbResource
openInputStream
in interface SmbResource
SmbException
public SmbFileInputStream openInputStream(int sharing) throws SmbException
SmbResource
openInputStream
in interface SmbResource
sharing
- flags indicating for which operations others may open the file (FILE_SHARING_*)SmbException
public SmbFileInputStream openInputStream(int flags, int access, int sharing) throws SmbException
SmbResource
openInputStream
in interface SmbResource
flags
- open flagsaccess
- desired access flagssharing
- flags indicating for which operations others may open the file (FILE_SHARING_*)SmbException
public OutputStream getOutputStream() throws IOException
getOutputStream
in class URLConnection
IOException
public SmbFileOutputStream openOutputStream() throws SmbException
SmbResource
openOutputStream
in interface SmbResource
SmbException
public SmbFileOutputStream openOutputStream(boolean append) throws SmbException
SmbResource
openOutputStream
in interface SmbResource
append
- whether to append to or truncate the inputSmbException
public SmbFileOutputStream openOutputStream(boolean append, int sharing) throws SmbException
SmbResource
openOutputStream
in interface SmbResource
append
- whether to append to or truncate the inputsharing
- flags indicating for which operations others may open the file (FILE_SHARING_*)SmbException
public SmbFileOutputStream openOutputStream(boolean append, int openFlags, int access, int sharing) throws SmbException
SmbResource
openOutputStream
in interface SmbResource
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 fileSmbException
public SmbRandomAccessFile openRandomAccess(String mode) throws SmbException
SmbResource
openRandomAccess
in interface SmbResource
mode
- access mode (r|rw)SmbException
public SmbRandomAccessFile openRandomAccess(String mode, int sharing) throws SmbException
SmbResource
openRandomAccess
in interface SmbResource
mode
- access mode (r|rw)sharing
- flags indicating for which operations others may concurrently open the fileSmbException
public long fileIndex() throws SmbException
SmbResource
fileIndex
in interface SmbResource
SmbException
public ACE[] getSecurity() throws IOException
SmbResource
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.
getSecurity
in interface SmbResource
IOException
public ACE[] getSecurity(boolean resolveSids) throws IOException
SmbResource
getSecurity
in interface SmbResource
resolveSids
- Attempt to resolve the SIDs within each ACE form
their numeric representation to their corresponding account names.IOException
public SID getOwnerUser() throws IOException
SmbResource
getOwnerUser
in interface SmbResource
null
if not presentIOException
public SID getOwnerUser(boolean resolve) throws IOException
SmbResource
getOwnerUser
in interface SmbResource
resolve
- whether to resolve the user namenull
if not presentIOException
public SID getOwnerGroup() throws IOException
SmbResource
getOwnerGroup
in interface SmbResource
null
if not presentIOException
public SID getOwnerGroup(boolean resolve) throws IOException
SmbResource
getOwnerGroup
in interface SmbResource
resolve
- whether to resolve the group namenull
if not presentIOException
public ACE[] getShareSecurity(boolean resolveSids) throws IOException
SmbResource
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.
getShareSecurity
in interface SmbResource
resolveSids
- Attempt to resolve the SIDs within each ACE form
their numeric representation to their corresponding account names.IOException
Copyright © 2017. All rights reserved.