KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jcifs > smb > Trans2SetFileInformation


1 /* jcifs smb client library in Java
2  * Copyright (C) 2003 "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 class Trans2SetFileInformation extends SmbComTransaction {
22
23     static final int SMB_FILE_BASIC_INFO = 0x101;
24
25     private int fid;
26     private int attributes;
27     private long createTime, lastWriteTime;
28
29     Trans2SetFileInformation( int fid, int attributes, long createTime, long lastWriteTime ) {
30         this.fid = fid;
31         this.attributes = attributes;
32         this.createTime = createTime;
33         this.lastWriteTime = lastWriteTime;
34         command = SMB_COM_TRANSACTION2;
35         subCommand = TRANS2_SET_FILE_INFORMATION;
36         maxParameterCount = 6;
37         maxDataCount = 0;
38         maxSetupCount = (byte)0x00;
39     }
40
41     int writeSetupWireFormat( byte[] dst, int dstIndex ) {
42         dst[dstIndex++] = subCommand;
43         dst[dstIndex++] = (byte)0x00;
44         return 2;
45     }
46     int writeParametersWireFormat( byte[] dst, int dstIndex ) {
47         int start = dstIndex;
48
49         writeInt2( fid, dst, dstIndex );
50         dstIndex += 2;
51         writeInt2( SMB_FILE_BASIC_INFO, dst, dstIndex );
52         dstIndex += 2;
53         writeInt2( 0, dst, dstIndex );
54         dstIndex += 2;
55
56         return dstIndex - start;
57     }
58     int writeDataWireFormat( byte[] dst, int dstIndex ) {
59         int start = dstIndex;
60
61         writeTime( createTime, dst, dstIndex ); dstIndex += 8;
62         writeInt8( 0L, dst, dstIndex ); dstIndex += 8;
63         writeTime( lastWriteTime, dst, dstIndex ); dstIndex += 8;
64         writeInt8( 0L, dst, dstIndex ); dstIndex += 8;
65 /* Samba 2.2.7 needs ATTR_NORMAL
66  */

67         writeInt2( 0x80 | attributes, dst, dstIndex ); dstIndex += 2;
68                                         /* 6 zeros observed with NT */
69         writeInt8( 0L, dst, dstIndex ); dstIndex += 6;
70
71                 /* Also observed 4 byte alignment but we stick
72                  * with the default for jCIFS which is 2 */

73
74         return dstIndex - start;
75     }
76     int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) {
77         return 0;
78     }
79     int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) {
80         return 0;
81     }
82     int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) {
83         return 0;
84     }
85     public String JavaDoc toString() {
86         return new String JavaDoc( "Trans2SetFileInformation[" + super.toString() +
87             ",fid=" + fid + "]" );
88     }
89 }
90
Popular Tags