001: /* jcifs smb client library in Java
002: * Copyright (C) 2003 "Michael B. Allen" <jcifs at samba dot org>
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2.1 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: */
018:
019: package jcifs.smb;
020:
021: class Trans2SetFileInformation extends SmbComTransaction {
022:
023: static final int SMB_FILE_BASIC_INFO = 0x101;
024:
025: private int fid;
026: private int attributes;
027: private long createTime, lastWriteTime;
028:
029: Trans2SetFileInformation(int fid, int attributes, long createTime,
030: long lastWriteTime) {
031: this .fid = fid;
032: this .attributes = attributes;
033: this .createTime = createTime;
034: this .lastWriteTime = lastWriteTime;
035: command = SMB_COM_TRANSACTION2;
036: subCommand = TRANS2_SET_FILE_INFORMATION;
037: maxParameterCount = 6;
038: maxDataCount = 0;
039: maxSetupCount = (byte) 0x00;
040: }
041:
042: int writeSetupWireFormat(byte[] dst, int dstIndex) {
043: dst[dstIndex++] = subCommand;
044: dst[dstIndex++] = (byte) 0x00;
045: return 2;
046: }
047:
048: int writeParametersWireFormat(byte[] dst, int dstIndex) {
049: int start = dstIndex;
050:
051: writeInt2(fid, dst, dstIndex);
052: dstIndex += 2;
053: writeInt2(SMB_FILE_BASIC_INFO, dst, dstIndex);
054: dstIndex += 2;
055: writeInt2(0, dst, dstIndex);
056: dstIndex += 2;
057:
058: return dstIndex - start;
059: }
060:
061: int writeDataWireFormat(byte[] dst, int dstIndex) {
062: int start = dstIndex;
063:
064: writeTime(createTime, dst, dstIndex);
065: dstIndex += 8;
066: writeInt8(0L, dst, dstIndex);
067: dstIndex += 8;
068: writeTime(lastWriteTime, dst, dstIndex);
069: dstIndex += 8;
070: writeInt8(0L, dst, dstIndex);
071: dstIndex += 8;
072: /* Samba 2.2.7 needs ATTR_NORMAL
073: */
074: writeInt2(0x80 | attributes, dst, dstIndex);
075: dstIndex += 2;
076: /* 6 zeros observed with NT */
077: writeInt8(0L, dst, dstIndex);
078: dstIndex += 6;
079:
080: /* Also observed 4 byte alignment but we stick
081: * with the default for jCIFS which is 2 */
082:
083: return dstIndex - start;
084: }
085:
086: int readSetupWireFormat(byte[] buffer, int bufferIndex, int len) {
087: return 0;
088: }
089:
090: int readParametersWireFormat(byte[] buffer, int bufferIndex, int len) {
091: return 0;
092: }
093:
094: int readDataWireFormat(byte[] buffer, int bufferIndex, int len) {
095: return 0;
096: }
097:
098: public String toString() {
099: return new String("Trans2SetFileInformation["
100: + super .toString() + ",fid=" + fid + "]");
101: }
102: }
|