@Override public boolean canRead () throws SmbException { if ( getType() == TYPE_NAMED_PIPE ) { // try opening the pipe for reading? return true; } return exists(); // try opening and catch sharing violation? }
@Override public boolean canWrite () throws SmbException { if ( getType() == TYPE_NAMED_PIPE ) { // try opening the pipe for writing? return true; } return exists() && ( this.attributes & ATTR_READONLY ) == 0; }
@Override public boolean canWrite () throws SmbException { if ( getType() == TYPE_NAMED_PIPE ) { // try opening the pipe for writing? return true; } return exists() && ( this.attributes & ATTR_READONLY ) == 0; }
@Override public boolean canRead () throws SmbException { if ( getType() == TYPE_NAMED_PIPE ) { // try opening the pipe for reading? return true; } return exists(); // try opening and catch sharing violation? }
/** * Tests to see if the file this <code>SmbFile</code> represents can be * read. Because any file, directory, or other resource can be read if it * exists, this method simply calls the <code>exists</code> method. * * @return <code>true</code> if the file is read-only */ public boolean canRead() throws SmbException { if( getType() == TYPE_NAMED_PIPE ) { // try opening the pipe for reading? return true; } return exists(); // try opening and catch sharing violation? }
/** * Tests to see if the file this <code>SmbFile</code> represents can be * read. Because any file, directory, or other resource can be read if it * exists, this method simply calls the <code>exists</code> method. * * @return <code>true</code> if the file is read-only */ public boolean canRead() throws SmbException { if( getType() == TYPE_NAMED_PIPE ) { // try opening the pipe for reading? return true; } return exists(); // try opening and catch sharing violation? }
/** * Tests to see if the file this <code>SmbFile</code> represents can be * read. Because any file, directory, or other resource can be read if it * exists, this method simply calls the <code>exists</code> method. * * @return <code>true</code> if the file is read-only */ public boolean canRead() throws SmbException { if( getType() == TYPE_NAMED_PIPE ) { // try opening the pipe for reading? return true; } return exists(); // try opening and catch sharing violation? }
/** * Tests to see if the file this <code>SmbFile</code> represents can be * read. Because any file, directory, or other resource can be read if it * exists, this method simply calls the <code>exists</code> method. * * @return <code>true</code> if the file is read-only */ public boolean canRead() throws SmbException { if( getType() == TYPE_NAMED_PIPE ) { // try opening the pipe for reading? return true; } return exists(); // try opening and catch sharing violation? }
/** * Tests to see if the file this <code>SmbFile</code> represents * exists and is not marked read-only. By default, resources are * considered to be read-only and therefore for <code>smb://</code>, * <code>smb://workgroup/</code>, and <code>smb://server/</code> resources * will be read-only. * * @return <code>true</code> if the resource exists is not marked * read-only */ public boolean canWrite() throws SmbException { if( getType() == TYPE_NAMED_PIPE ) { // try opening the pipe for writing? return true; } return exists() && ( attributes & ATTR_READONLY ) == 0; }
/** * Tests to see if the file this <code>SmbFile</code> represents * exists and is not marked read-only. By default, resources are * considered to be read-only and therefore for <code>smb://</code>, * <code>smb://workgroup/</code>, and <code>smb://server/</code> resources * will be read-only. * * @return <code>true</code> if the resource exists is not marked * read-only */ public boolean canWrite() throws SmbException { if( getType() == TYPE_NAMED_PIPE ) { // try opening the pipe for writing? return true; } return exists() && ( attributes & ATTR_READONLY ) == 0; }
/** * Tests to see if the file this <code>SmbFile</code> represents * exists and is not marked read-only. By default, resources are * considered to be read-only and therefore for <code>smb://</code>, * <code>smb://workgroup/</code>, and <code>smb://server/</code> resources * will be read-only. * * @return <code>true</code> if the resource exists is not marked * read-only */ public boolean canWrite() throws SmbException { if( getType() == TYPE_NAMED_PIPE ) { // try opening the pipe for writing? return true; } return exists() && ( attributes & ATTR_READONLY ) == 0; }
/** * Tests to see if the file this <code>SmbFile</code> represents * exists and is not marked read-only. By default, resources are * considered to be read-only and therefore for <code>smb://</code>, * <code>smb://workgroup/</code>, and <code>smb://server/</code> resources * will be read-only. * * @return <code>true</code> if the resource exists is not marked * read-only */ public boolean canWrite() throws SmbException { if( getType() == TYPE_NAMED_PIPE ) { // try opening the pipe for writing? return true; } return exists() && ( attributes & ATTR_READONLY ) == 0; }
void doEnum(ArrayList list, boolean files, String wildcard, int searchAttributes, SmbFilenameFilter fnf, SmbFileFilter ff) throws SmbException { if (ff != null && ff instanceof DosFileFilter) { DosFileFilter dff = (DosFileFilter)ff; if (dff.wildcard != null) wildcard = dff.wildcard; searchAttributes = dff.attributes; } try { int hostlen = url.getHost().length(); if (hostlen == 0 || getType() == TYPE_WORKGROUP) { doNetServerEnum(list, files, wildcard, searchAttributes, fnf, ff); } else if (share == null) { doShareEnum(list, files, wildcard, searchAttributes, fnf, ff); } else { doFindFirstNext(list, files, wildcard, searchAttributes, fnf, ff); } } catch (UnknownHostException uhe) { throw new SmbException(url.toString(), uhe); } catch (MalformedURLException mue) { throw new SmbException(url.toString(), mue); } } void doShareEnum(ArrayList list,
/** * 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. Objects * other than <tt>TYPE_SHARE</tt> or <tt>TYPE_FILESYSTEM</tt> will result * in 0L being returned. * * @return the free disk space in bytes of the drive on which this file or * directory resides */ public long getDiskFreeSpace() throws SmbException { if( getType() == TYPE_SHARE || type == TYPE_FILESYSTEM ) { int level = Trans2QueryFSInformationResponse.SMB_FS_FULL_SIZE_INFORMATION; try { return queryFSInformation(level); } catch( SmbException ex ) { switch (ex.getNtStatus()) { case NtStatus.NT_STATUS_INVALID_INFO_CLASS: case NtStatus.NT_STATUS_UNSUCCESSFUL: // NetApp Filer // SMB_FS_FULL_SIZE_INFORMATION not supported by the server. level = Trans2QueryFSInformationResponse.SMB_INFO_ALLOCATION; return queryFSInformation(level); } throw ex; } } return 0L; }
SmbFileInputStream ( SmbFile file, int openFlags, int access, int sharing, boolean unshared ) throws SmbException { this.file = file; this.unsharedFile = unshared; this.openFlags = openFlags; this.access = access; try ( SmbTreeHandleInternal th = file.ensureTreeConnected() ) { this.smb2 = th.isSMB2(); if ( file.getType() != SmbConstants.TYPE_NAMED_PIPE ) { try ( SmbFileHandle h = ensureOpen() ) {} this.openFlags &= ~ ( SmbConstants.O_CREAT | SmbConstants.O_TRUNC ); } init(th); } catch ( CIFSException e ) { throw SmbException.wrap(e); } }
SmbFileInputStream ( SmbFile file, int openFlags, int access, int sharing, boolean unshared ) throws SmbException { this.file = file; this.unsharedFile = unshared; this.openFlags = openFlags; this.access = access; try ( SmbTreeHandleInternal th = file.ensureTreeConnected() ) { this.smb2 = th.isSMB2(); if ( file.getType() != SmbConstants.TYPE_NAMED_PIPE ) { try ( SmbFileHandle h = ensureOpen() ) {} this.openFlags &= ~ ( SmbConstants.O_CREAT | SmbConstants.O_TRUNC ); } init(th); } catch ( CIFSException e ) { throw SmbException.wrap(e); } }
@Override public long getDiskFreeSpace () throws SmbException { try ( SmbTreeHandleImpl th = ensureTreeConnected() ) { int t = getType(); if ( t == TYPE_SHARE || t == TYPE_FILESYSTEM ) { AllocInfo allocInfo = fetchAllocationInfo(th); this.size = allocInfo.getCapacity(); this.sizeExpiration = System.currentTimeMillis() + getContext().getConfig().getAttributeCacheTimeout(); return allocInfo.getFree(); } return 0L; } catch ( CIFSException e ) { throw SmbException.wrap(e); } }
@Override public long getDiskFreeSpace () throws SmbException { try ( SmbTreeHandleImpl th = ensureTreeConnected() ) { int t = getType(); if ( t == TYPE_SHARE || t == TYPE_FILESYSTEM ) { AllocInfo allocInfo = fetchAllocationInfo(th); this.size = allocInfo.getCapacity(); this.sizeExpiration = System.currentTimeMillis() + getContext().getConfig().getAttributeCacheTimeout(); return allocInfo.getFree(); } return 0L; } catch ( CIFSException e ) { throw SmbException.wrap(e); } }
@Override public long length () throws SmbException { if ( this.sizeExpiration > System.currentTimeMillis() ) { return this.size; } try ( SmbTreeHandleImpl th = ensureTreeConnected() ) { int t = getType(); if ( t == TYPE_SHARE ) { this.size = fetchAllocationInfo(th).getCapacity(); } else if ( !this.fileLocator.isRoot() && t != TYPE_NAMED_PIPE ) { queryPath(th, this.fileLocator.getUNCPath(), FileInformation.FILE_STANDARD_INFO); } else { this.size = 0L; } this.sizeExpiration = System.currentTimeMillis() + getContext().getConfig().getAttributeCacheTimeout(); return this.size; } catch ( CIFSException e ) { throw SmbException.wrap(e); } }
@Override public long length () throws SmbException { if ( this.sizeExpiration > System.currentTimeMillis() ) { return this.size; } try ( SmbTreeHandleImpl th = ensureTreeConnected() ) { int t = getType(); if ( t == TYPE_SHARE ) { this.size = fetchAllocationInfo(th).getCapacity(); } else if ( !this.fileLocator.isRoot() && t != TYPE_NAMED_PIPE ) { queryPath(th, this.fileLocator.getUNCPath(), FileInformation.FILE_STANDARD_INFO); } else { this.size = 0L; } this.sizeExpiration = System.currentTimeMillis() + getContext().getConfig().getAttributeCacheTimeout(); return this.size; } catch ( CIFSException e ) { throw SmbException.wrap(e); } }