@Override public String getShare () { if ( this.unc == null ) { canonicalizePath(); } return this.share; }
/** * Returns the Windows UNC style path with backslashes instead of forward slashes. * * @return The UNC path. */ public String getCanonicalUncPath () { return this.fileLocator.getCanonicalURL(); }
@Override public Address getAddress () throws CIFSException { if ( this.addressIndex == 0 ) return getFirstAddress(); return this.addresses[ this.addressIndex - 1 ]; }
static CloseableIterator<SmbResource> doShareEnum ( SmbFile parent, String wildcard, int searchAttributes, ResourceNameFilter fnf, ResourceFilter ff ) throws CIFSException { SmbResourceLocatorImpl locator = parent.fileLocator.clone(); CIFSContext tc = parent.getContext(); URL u = locator.getURL(); throw new SmbException(u.toString() + " directory must end with '/'"); if ( locator.getType() != SmbConstants.TYPE_SERVER ) throw new SmbException("The requested list operations is invalid: " + u.toString()); if ( tc.getDfs().isTrustedDomain(tc, locator.getServer()) ) { entries = doDfsRootEnum(tc, locator, locator.getAddress()); for ( int ei = 0; ei < entries.length; ei++ ) { FileEntry e = entries[ ei ]; try ( SmbTreeHandleImpl th = treeConn.connectHost(locator, locator.getServerWithDfs()); SmbSessionImpl session = th.getSession(); SmbTransportImpl transport = session.getTransport() ) {
/** * {@inheritDoc} * * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals ( Object obj ) { if ( ! ( obj instanceof SmbResourceLocatorImpl ) ) { return false; } SmbResourceLocatorImpl o = (SmbResourceLocatorImpl) obj; /* * If uncertain, pathNamesPossiblyEqual returns true. * Comparing canonical paths is definitive. */ if ( pathNamesPossiblyEqual(this.url.getPath(), o.url.getPath()) ) { if ( getURLPath().equalsIgnoreCase(o.getURLPath()) ) { try { return getAddress().equals(o.getAddress()); } catch ( CIFSException uhe ) { log.debug("Unknown host", uhe); return getServer().equalsIgnoreCase(o.getServer()); } } } return false; }
/** * {@inheritDoc} * * @see java.lang.Object#hashCode() */ @Override public int hashCode () { int hash; try { hash = getAddress().hashCode(); } catch ( CIFSException uhe ) { hash = getServer().toUpperCase().hashCode(); } return hash + getURLPath().toUpperCase().hashCode(); }
public int getType () throws CIFSException { if ( this.type == 0 ) { if ( getUNCPath().length() > 1 ) { this.type = SmbConstants.TYPE_FILESYSTEM; else if ( getShare() != null ) { if ( getShare().equals("IPC$") ) { this.type = SmbConstants.TYPE_NAMED_PIPE; NetbiosAddress nbaddr = getAddress().unwrap(NetbiosAddress.class); if ( nbaddr != null ) { int code = nbaddr.getNameType();
/** * * {@inheritDoc} * * @see jcifs.smb.SmbResourceLocatorInternal#overlaps(jcifs.SmbResourceLocator) */ @Override public boolean overlaps ( SmbResourceLocator other ) throws CIFSException { String tp = getCanonicalURL(); String op = other.getCanonicalURL(); return getAddress().equals(other.getAddress()) && tp.regionMatches(true, 0, op, 0, Math.min(tp.length(), op.length())); }
/** * {@inheritDoc} * * @see jcifs.SmbResourceLocator#isWorkgroup() */ @Override public boolean isWorkgroup () throws CIFSException { if ( this.type == SmbConstants.TYPE_WORKGROUP || this.url.getHost().length() == 0 ) { this.type = SmbConstants.TYPE_WORKGROUP; return true; } if ( getShare() == null ) { NetbiosAddress addr = getAddress().unwrap(NetbiosAddress.class); if ( addr != null ) { int code = addr.getNameType(); if ( code == 0x1d || code == 0x1b ) { this.type = SmbConstants.TYPE_WORKGROUP; return true; } } this.type = SmbConstants.TYPE_SERVER; } return false; }
try { if ( query != null ) { String server = queryLookup(query, "server"); if ( server != null && server.length() > 0 ) { this.addresses = new UniAddress[1]; this.addresses[ 0 ] = this.ctx.getNameServiceClient().getByName(server); String address = queryLookup(query, "address"); if ( address != null && address.length() > 0 ) { byte[] ip = java.net.InetAddress.getByName(address).getAddress(); return getNextAddress();
/** * Everything but the last component of the URL representing this SMB * resource is effectively it's parent. The root URL <code>smb://</code> * does not have a parent. In this case <code>smb://</code> is returned. * * @return The parent directory of this SMB resource or * <code>smb://</code> if the resource refers to the root of the URL * hierarchy which incidentally is also <code>smb://</code>. */ public String getParent () { return this.fileLocator.getParent(); }
/** * {@inheritDoc} * * @see java.lang.Object#clone() */ @Override protected SmbResourceLocatorImpl clone () { SmbResourceLocatorImpl loc = new SmbResourceLocatorImpl(this.ctx, this.url); loc.canon = this.canon; loc.share = this.share; loc.dfsReferral = this.dfsReferral; loc.unc = this.unc; if ( this.addresses != null ) { loc.addresses = new UniAddress[this.addresses.length]; System.arraycopy(this.addresses, 0, loc.addresses, 0, this.addresses.length); } loc.addressIndex = this.addressIndex; loc.type = this.type; return loc; }
@Override public String getName () { return this.fileLocator.getName(); }
return true; return this.fileLocator.equals(f.getLocator());
static CloseableIterator<SmbResource> doShareEnum ( SmbFile parent, String wildcard, int searchAttributes, ResourceNameFilter fnf, ResourceFilter ff ) throws CIFSException { SmbResourceLocatorImpl locator = parent.fileLocator.clone(); CIFSContext tc = parent.getContext(); URL u = locator.getURL(); throw new SmbException(u.toString() + " directory must end with '/'"); if ( locator.getType() != SmbConstants.TYPE_SERVER ) throw new SmbException("The requested list operations is invalid: " + u.toString()); if ( tc.getDfs().isTrustedDomain(tc, locator.getServer()) ) { entries = doDfsRootEnum(tc, locator, locator.getAddress()); for ( int ei = 0; ei < entries.length; ei++ ) { FileEntry e = entries[ ei ]; try ( SmbTreeHandleImpl th = treeConn.connectHost(locator, locator.getServerWithDfs()); SmbSessionImpl session = th.getSession(); SmbTransportImpl transport = session.getTransport() ) {
/** * {@inheritDoc} * * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals ( Object obj ) { if ( ! ( obj instanceof SmbResourceLocatorImpl ) ) { return false; } SmbResourceLocatorImpl o = (SmbResourceLocatorImpl) obj; /* * If uncertain, pathNamesPossiblyEqual returns true. * Comparing canonical paths is definitive. */ if ( pathNamesPossiblyEqual(this.url.getPath(), o.url.getPath()) ) { if ( getURLPath().equalsIgnoreCase(o.getURLPath()) ) { try { return getAddress().equals(o.getAddress()); } catch ( CIFSException uhe ) { log.debug("Unknown host", uhe); return getServer().equalsIgnoreCase(o.getServer()); } } } return false; }
/** * {@inheritDoc} * * @see java.lang.Object#hashCode() */ @Override public int hashCode () { int hash; try { hash = getAddress().hashCode(); } catch ( CIFSException uhe ) { hash = getServer().toUpperCase().hashCode(); } return hash + getURLPath().toUpperCase().hashCode(); }
public int getType () throws CIFSException { if ( this.type == 0 ) { if ( getUNCPath().length() > 1 ) { this.type = SmbConstants.TYPE_FILESYSTEM; else if ( getShare() != null ) { if ( getShare().equals("IPC$") ) { this.type = SmbConstants.TYPE_NAMED_PIPE; NetbiosAddress nbaddr = getAddress().unwrap(NetbiosAddress.class); if ( nbaddr != null ) { int code = nbaddr.getNameType();
/** * * {@inheritDoc} * * @see jcifs.smb.SmbResourceLocatorInternal#overlaps(jcifs.SmbResourceLocator) */ @Override public boolean overlaps ( SmbResourceLocator other ) throws CIFSException { String tp = getCanonicalURL(); String op = other.getCanonicalURL(); return getAddress().equals(other.getAddress()) && tp.regionMatches(true, 0, op, 0, Math.min(tp.length(), op.length())); }
/** * {@inheritDoc} * * @see jcifs.SmbResourceLocator#isWorkgroup() */ @Override public boolean isWorkgroup () throws CIFSException { if ( this.type == SmbConstants.TYPE_WORKGROUP || this.url.getHost().length() == 0 ) { this.type = SmbConstants.TYPE_WORKGROUP; return true; } if ( getShare() == null ) { NetbiosAddress addr = getAddress().unwrap(NetbiosAddress.class); if ( addr != null ) { int code = addr.getNameType(); if ( code == 0x1d || code == 0x1b ) { this.type = SmbConstants.TYPE_WORKGROUP; return true; } } this.type = SmbConstants.TYPE_SERVER; } return false; }