KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jcifs > smb > Trans2FindFirst2


1 /* jcifs smb client library in Java
2  * Copyright (C) 2000 "Michael B. Allen" <jcifs at samba dot org>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18
19 package jcifs.smb;
20
21 import jcifs.Config;
22 import jcifs.util.Hexdump;
23
24 class Trans2FindFirst2 extends SmbComTransaction {
25
26     // flags
27

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 JavaDoc wildcard;
42
43     // information levels
44

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 JavaDoc filename, String JavaDoc 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; /* generally ignored tho */
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 JavaDoc toString() {
111         return new String JavaDoc( "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