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