1 18 19 package com.knowgate.jcifs.smb; 20 21 import java.util.Date ; 22 23 import com.knowgate.misc.Gadgets; 24 25 class Trans2QueryPathInformationResponse extends SmbComTransactionResponse { 26 27 static final int SMB_QUERY_FILE_BASIC_INFO = 0x101; 29 static final int SMB_QUERY_FILE_STANDARD_INFO = 0x102; 30 31 class SmbQueryFileBasicInfo implements Info { 32 long createTime; 33 long lastAccessTime; 34 long lastWriteTime; 35 long changeTime; 36 int attributes; 37 38 public int getAttributes() { 39 return attributes; 40 } 41 public long getCreateTime() { 42 return createTime; 43 } 44 public long getLastWriteTime() { 45 return lastWriteTime; 46 } 47 public long getSize() { 48 return 0L; 49 } 50 public String toString() { 51 return new String ( "SmbQueryFileBasicInfo[" + 52 "createTime=" + new Date ( createTime ) + 53 ",lastAccessTime=" + new Date ( lastAccessTime ) + 54 ",lastWriteTime=" + new Date ( lastWriteTime ) + 55 ",changeTime=" + new Date ( changeTime ) + 56 ",attributes=0x" + Gadgets.toHexString( attributes, 4 ) + "]" ); 57 } 58 } 59 class SmbQueryFileStandardInfo implements Info { 60 long allocationSize; 61 long endOfFile; 62 int numberOfLinks; 63 boolean deletePending; 64 boolean directory; 65 66 public int getAttributes() { 67 return 0; 68 } 69 public long getCreateTime() { 70 return 0L; 71 } 72 public long getLastWriteTime() { 73 return 0L; 74 } 75 public long getSize() { 76 return endOfFile; 77 } 78 public String toString() { 79 return new String ( "SmbQueryInfoStandard[" + 80 "allocationSize=" + allocationSize + 81 ",endOfFile=" + endOfFile + 82 ",numberOfLinks=" + numberOfLinks + 83 ",deletePending=" + deletePending + 84 ",directory=" + directory + "]" ); 85 } 86 } 87 88 private int informationLevel; 89 90 Info info; 91 92 Trans2QueryPathInformationResponse( int informationLevel ) { 93 this.informationLevel = informationLevel; 94 subCommand = SmbComTransaction.TRANS2_QUERY_PATH_INFORMATION; 95 } 96 97 int writeSetupWireFormat( byte[] dst, int dstIndex ) { 98 return 0; 99 } 100 int writeParametersWireFormat( byte[] dst, int dstIndex ) { 101 return 0; 102 } 103 int writeDataWireFormat( byte[] dst, int dstIndex ) { 104 return 0; 105 } 106 int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) { 107 return 0; 108 } 109 int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) { 110 return 2; 112 } 113 int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) { 114 switch( informationLevel ) { 115 case SMB_QUERY_FILE_BASIC_INFO: 116 return readSmbQueryFileBasicInfoWireFormat( buffer, bufferIndex ); 117 case SMB_QUERY_FILE_STANDARD_INFO: 118 return readSmbQueryFileStandardInfoWireFormat( buffer, bufferIndex ); 119 default: 120 return 0; 121 } 122 } 123 int readSmbQueryFileStandardInfoWireFormat( byte[] buffer, int bufferIndex ) { 124 int start = bufferIndex; 125 126 SmbQueryFileStandardInfo info = new SmbQueryFileStandardInfo(); 127 info.allocationSize = readInt8( buffer, bufferIndex ); 128 bufferIndex += 8; 129 info.endOfFile = readInt8( buffer, bufferIndex ); 130 bufferIndex += 8; 131 info.numberOfLinks = readInt4( buffer, bufferIndex ); 132 bufferIndex += 4; 133 info.deletePending = ( buffer[bufferIndex++] & 0xFF ) > 0; 134 info.directory = ( buffer[bufferIndex++] & 0xFF ) > 0; 135 this.info = info; 136 137 return bufferIndex - start; 138 } 139 int readSmbQueryFileBasicInfoWireFormat( byte[] buffer, int bufferIndex ) { 140 int start = bufferIndex; 141 142 SmbQueryFileBasicInfo info = new SmbQueryFileBasicInfo(); 143 info.createTime = readTime( buffer, bufferIndex ); 144 bufferIndex += 8; 145 info.lastAccessTime = readTime( buffer, bufferIndex ); 146 bufferIndex += 8; 147 info.lastWriteTime = readTime( buffer, bufferIndex ); 148 bufferIndex += 8; 149 info.changeTime = readTime( buffer, bufferIndex ); 150 bufferIndex += 8; 151 info.attributes = readInt2( buffer, bufferIndex ); 152 bufferIndex += 2; 153 this.info = info; 154 155 return bufferIndex - start; 156 } 157 public String toString() { 158 return new String ( "Trans2QueryPathInformationResponse[" + 159 super.toString() + "]" ); 160 } 161 } 162 | Popular Tags |