2
0

Trans2SetFileInformation.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // This code is derived from jcifs smb client library <jcifs at samba dot org>
  2. // Ported by J. Arturo <webmaster at komodosoft dot net>
  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. namespace SharpCifs.Smb
  18. {
  19. internal class Trans2SetFileInformation : SmbComTransaction
  20. {
  21. internal const int SmbFileBasicInfo = unchecked(0x101);
  22. private int _fid;
  23. private int _attributes;
  24. private long _createTime;
  25. private long _lastWriteTime;
  26. internal Trans2SetFileInformation(int fid,
  27. int attributes,
  28. long createTime,
  29. long lastWriteTime)
  30. {
  31. this._fid = fid;
  32. this._attributes = attributes;
  33. this._createTime = createTime;
  34. this._lastWriteTime = lastWriteTime;
  35. Command = SmbComTransaction2;
  36. SubCommand = Trans2SetFileInformation;
  37. MaxParameterCount = 6;
  38. MaxDataCount = 0;
  39. MaxSetupCount = unchecked(unchecked(0x00));
  40. }
  41. internal override int WriteSetupWireFormat(byte[] dst, int dstIndex)
  42. {
  43. dst[dstIndex++] = SubCommand;
  44. dst[dstIndex++] = unchecked(unchecked(0x00));
  45. return 2;
  46. }
  47. internal override int WriteParametersWireFormat(byte[] dst, int dstIndex)
  48. {
  49. int start = dstIndex;
  50. WriteInt2(_fid, dst, dstIndex);
  51. dstIndex += 2;
  52. WriteInt2(SmbFileBasicInfo, dst, dstIndex);
  53. dstIndex += 2;
  54. WriteInt2(0, dst, dstIndex);
  55. dstIndex += 2;
  56. return dstIndex - start;
  57. }
  58. internal override int WriteDataWireFormat(byte[] dst, int dstIndex)
  59. {
  60. int start = dstIndex;
  61. WriteTime(_createTime, dst, dstIndex);
  62. dstIndex += 8;
  63. WriteInt8(0L, dst, dstIndex);
  64. dstIndex += 8;
  65. WriteTime(_lastWriteTime, dst, dstIndex);
  66. dstIndex += 8;
  67. WriteInt8(0L, dst, dstIndex);
  68. dstIndex += 8;
  69. WriteInt2(unchecked(0x80) | _attributes, dst, dstIndex);
  70. dstIndex += 2;
  71. WriteInt8(0L, dst, dstIndex);
  72. dstIndex += 6;
  73. return dstIndex - start;
  74. }
  75. internal override int ReadSetupWireFormat(byte[] buffer,
  76. int bufferIndex,
  77. int len)
  78. {
  79. return 0;
  80. }
  81. internal override int ReadParametersWireFormat(byte[] buffer,
  82. int bufferIndex,
  83. int len)
  84. {
  85. return 0;
  86. }
  87. internal override int ReadDataWireFormat(byte[] buffer,
  88. int bufferIndex,
  89. int len)
  90. {
  91. return 0;
  92. }
  93. public override string ToString()
  94. {
  95. return "Trans2SetFileInformation["
  96. + base.ToString()
  97. + ",fid=" + _fid + "]";
  98. }
  99. }
  100. }