@Override public synchronized SmbFileHandleImpl ensureOpen () throws CIFSException { if ( !this.open ) { throw new SmbException("Pipe handle already closed"); } if ( !isOpen() ) { try ( SmbTreeHandleImpl th = ensureTreeConnected() ) { if ( th.isSMB2() ) { this.handle = this.pipe.openUnshared(this.uncPath, this.openFlags, this.access, this.sharing, SmbConstants.ATTR_NORMAL, 0); return this.handle.acquire(); } // TODO: wait for pipe, still not sure when this needs to be called exactly if ( this.uncPath.startsWith("\\pipe\\") ) { th.send(new TransWaitNamedPipe(th.getConfig(), this.uncPath), new TransWaitNamedPipeResponse(th.getConfig())); } if ( th.hasCapability(SmbConstants.CAP_NT_SMBS) || this.uncPath.startsWith("\\pipe\\") ) { this.handle = this.pipe.openUnshared(this.openFlags, this.access, this.sharing, SmbConstants.ATTR_NORMAL, 0); } else { // at least on samba, SmbComOpenAndX fails without the pipe prefix this.handle = this.pipe .openUnshared("\\pipe" + getUncPath(), this.openFlags, this.access, this.sharing, SmbConstants.ATTR_NORMAL, 0); } // one extra acquire to keep this open till the stream is released return this.handle.acquire(); } } log.trace("Pipe already open"); return this.handle.acquire(); }
@Override public synchronized SmbFileHandleImpl ensureOpen () throws CIFSException { if ( !this.open ) { throw new SmbException("Pipe handle already closed"); } if ( !isOpen() ) { try ( SmbTreeHandleImpl th = ensureTreeConnected() ) { if ( th.isSMB2() ) { this.handle = this.pipe.openUnshared(this.uncPath, this.openFlags, this.access, this.sharing, SmbConstants.ATTR_NORMAL, 0); return this.handle.acquire(); } // TODO: wait for pipe, still not sure when this needs to be called exactly if ( this.uncPath.startsWith("\\pipe\\") ) { th.send(new TransWaitNamedPipe(th.getConfig(), this.uncPath), new TransWaitNamedPipeResponse(th.getConfig())); } if ( th.hasCapability(SmbConstants.CAP_NT_SMBS) || this.uncPath.startsWith("\\pipe\\") ) { this.handle = this.pipe.openUnshared(this.openFlags, this.access, this.sharing, SmbConstants.ATTR_NORMAL, 0); } else { // at least on samba, SmbComOpenAndX fails without the pipe prefix this.handle = this.pipe .openUnshared("\\pipe" + getUncPath(), this.openFlags, this.access, this.sharing, SmbConstants.ATTR_NORMAL, 0); } // one extra acquire to keep this open till the stream is released return this.handle.acquire(); } } log.trace("Pipe already open"); return this.handle.acquire(); }