1 18 19 package com.knowgate.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 30 TransactNamedPipeOutputStream( SmbNamedPipe pipe ) throws IOException { 31 this.pipe = pipe; 32 path = pipe.unc; 33 } 34 35 public void close() throws IOException { 36 pipe.close(); 37 } 38 public void write( int b ) throws IOException { 39 tmp[0] = (byte)b; 40 write( tmp, 0, 1 ); 41 } 42 public void write( byte[] b ) throws IOException { 43 write( b, 0, b.length ); 44 } 45 public void write( byte[] b, int off, int len ) throws IOException { 46 if( len < 0 ) { 47 len = 0; 48 } 49 50 if(( pipe.pipeType & SmbNamedPipe.PIPE_TYPE_CALL ) == 51 SmbNamedPipe.PIPE_TYPE_CALL ) { 52 pipe.sendTransaction( new TransWaitNamedPipe( path ), 53 new TransWaitNamedPipeResponse() ); 54 pipe.sendTransaction( new TransCallNamedPipe( path, b, off, len ), 55 new TransCallNamedPipeResponse( pipe )); 56 } else if(( pipe.pipeType & SmbNamedPipe.PIPE_TYPE_TRANSACT ) == 57 SmbNamedPipe.PIPE_TYPE_TRANSACT ) { 58 pipe.open(( pipe.pipeType & 0xFF0000 ) | SmbFile.O_EXCL, SmbFile.ATTR_NORMAL, 0 ); 59 pipe.sendTransaction( new TransTransactNamedPipe( pipe.fid, b, off, len ), 60 new TransTransactNamedPipeResponse( pipe )); 61 } 62 } 63 } 64 | Popular Tags |