1 18 19 package jcifs.smb; 20 21 import jcifs.Config; 22 import jcifs.util.Hexdump; 23 24 class Trans2FindFirst2 extends SmbComTransaction { 25 26 28 private static final int FLAGS_CLOSE_AFTER_THIS_REQUEST = 0x01; 29 private static final int FLAGS_CLOSE_IF_END_REACHED = 0x02; 30 private static final int FLAGS_RETURN_RESUME_KEYS = 0x04; 31 private static final int FLAGS_RESUME_FROM_PREVIOUS_END = 0x08; 32 private static final int FLAGS_FIND_WITH_BACKUP_INTENT = 0x10; 33 34 private static final int DEFAULT_LIST_SIZE = 65535; 35 private static final int DEFAULT_LIST_COUNT = 200; 36 37 private int searchAttributes; 38 private int flags; 39 private int informationLevel; 40 private int searchStorageType = 0; 41 private String wildcard; 42 43 45 static final int SMB_INFO_STANDARD = 1; 46 static final int SMB_INFO_QUERY_EA_SIZE = 2; 47 static final int SMB_INFO_QUERY_EAS_FROM_LIST = 3; 48 static final int SMB_FIND_FILE_DIRECTORY_INFO = 0x101; 49 static final int SMB_FIND_FILE_FULL_DIRECTORY_INFO = 0x102; 50 static final int SMB_FILE_NAMES_INFO = 0x103; 51 static final int SMB_FILE_BOTH_DIRECTORY_INFO = 0x104; 52 53 static final int LIST_SIZE = Config.getInt( "jcifs.smb.client.listSize", DEFAULT_LIST_SIZE ); 54 static final int LIST_COUNT = Config.getInt( "jcifs.smb.client.listCount", DEFAULT_LIST_COUNT ); 55 56 Trans2FindFirst2( String filename, String wildcard, int searchAttributes ) { 57 if( filename.equals( "\\" )) { 58 this.path = filename; 59 } else { 60 this.path = filename + "\\"; 61 } 62 this.wildcard = wildcard; 63 this.searchAttributes = searchAttributes & 0x37; 64 command = SMB_COM_TRANSACTION2; 65 subCommand = TRANS2_FIND_FIRST2; 66 67 flags = 0x00; 68 informationLevel = SMB_FILE_BOTH_DIRECTORY_INFO; 69 70 totalDataCount = 0; 71 maxParameterCount = 10; 72 maxDataCount = LIST_SIZE; 73 maxSetupCount = 0; 74 } 75 76 int writeSetupWireFormat( byte[] dst, int dstIndex ) { 77 dst[dstIndex++] = subCommand; 78 dst[dstIndex++] = (byte)0x00; 79 return 2; 80 } 81 int writeParametersWireFormat( byte[] dst, int dstIndex ) { 82 int start = dstIndex; 83 84 writeInt2( searchAttributes, dst, dstIndex ); 85 dstIndex += 2; 86 writeInt2( LIST_COUNT, dst, dstIndex ); 87 dstIndex += 2; 88 writeInt2( flags, dst, dstIndex ); 89 dstIndex += 2; 90 writeInt2( informationLevel, dst, dstIndex ); 91 dstIndex += 2; 92 writeInt4( searchStorageType, dst, dstIndex ); 93 dstIndex += 4; 94 dstIndex += writeString( path + wildcard, dst, dstIndex ); 95 96 return dstIndex - start; 97 } 98 int writeDataWireFormat( byte[] dst, int dstIndex ) { 99 return 0; 100 } 101 int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) { 102 return 0; 103 } 104 int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) { 105 return 0; 106 } 107 int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) { 108 return 0; 109 } 110 public String toString() { 111 return new String ( "Trans2FindFirst2[" + super.toString() + 112 ",searchAttributes=0x" + Hexdump.toHexString( searchAttributes, 2 ) + 113 ",searchCount=" + LIST_COUNT + 114 ",flags=0x" + Hexdump.toHexString( flags, 2 ) + 115 ",informationLevel=0x" + Hexdump.toHexString( informationLevel, 3 ) + 116 ",searchStorageType=" + searchStorageType + 117 ",filename=" + path + "]" ); 118 } 119 } 120 | Popular Tags |