1 18 19 package jcifs.smb; 20 21 import java.io.OutputStream ; 22 import java.io.IOException ; 23 24 class TransactNamedPipeOutputStream extends OutputStream { 25 26 private String path; 27 private SmbNamedPipe pipe; 28 private byte[] tmp = new byte[1]; 29 private boolean dcePipe; 30 31 TransactNamedPipeOutputStream( SmbNamedPipe pipe ) throws IOException { 32 this.pipe = pipe; 33 this.dcePipe = ( pipe.pipeType & SmbNamedPipe.PIPE_TYPE_DCE_TRANSACT ) == SmbNamedPipe.PIPE_TYPE_DCE_TRANSACT; 34 path = pipe.unc; 35 } 36 37 public void close() throws IOException { 38 pipe.close(); 39 } 40 public void write( int b ) throws IOException { 41 tmp[0] = (byte)b; 42 write( tmp, 0, 1 ); 43 } 44 public void write( byte[] b ) throws IOException { 45 write( b, 0, b.length ); 46 } 47 public void write( byte[] b, int off, int len ) throws IOException { 48 if( len < 0 ) { 49 len = 0; 50 } 51 52 if(( pipe.pipeType & SmbNamedPipe.PIPE_TYPE_CALL ) == 53 SmbNamedPipe.PIPE_TYPE_CALL ) { 54 pipe.send( new TransWaitNamedPipe( path ), 55 new TransWaitNamedPipeResponse() ); 56 pipe.send( new TransCallNamedPipe( path, b, off, len ), 57 new TransCallNamedPipeResponse( pipe )); 58 } else if(( pipe.pipeType & SmbNamedPipe.PIPE_TYPE_TRANSACT ) == 59 SmbNamedPipe.PIPE_TYPE_TRANSACT ) { 60 pipe.open(( pipe.pipeType & 0xFFFF0000 ) | SmbFile.O_EXCL, SmbFile.ATTR_NORMAL, 0 ); 61 TransTransactNamedPipe req = new TransTransactNamedPipe( pipe.fid, b, off, len ); 62 if (dcePipe) { 63 req.maxDataCount = 1024; 64 } 65 pipe.send( req, new TransTransactNamedPipeResponse( pipe )); 66 } 67 } 68 } 69 | Popular Tags |