Trans2SetFileInformation.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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, int attributes, long createTime, long
  27. lastWriteTime)
  28. {
  29. this._fid = fid;
  30. this._attributes = attributes;
  31. this._createTime = createTime;
  32. this._lastWriteTime = lastWriteTime;
  33. Command = SmbComTransaction2;
  34. SubCommand = Trans2SetFileInformation;
  35. MaxParameterCount = 6;
  36. MaxDataCount = 0;
  37. MaxSetupCount = unchecked(unchecked(0x00));
  38. }
  39. internal override int WriteSetupWireFormat(byte[] dst, int dstIndex)
  40. {
  41. dst[dstIndex++] = SubCommand;
  42. dst[dstIndex++] = unchecked(unchecked(0x00));
  43. return 2;
  44. }
  45. internal override int WriteParametersWireFormat(byte[] dst, int dstIndex)
  46. {
  47. int start = dstIndex;
  48. WriteInt2(_fid, dst, dstIndex);
  49. dstIndex += 2;
  50. WriteInt2(SmbFileBasicInfo, dst, dstIndex);
  51. dstIndex += 2;
  52. WriteInt2(0, dst, dstIndex);
  53. dstIndex += 2;
  54. return dstIndex - start;
  55. }
  56. internal override int WriteDataWireFormat(byte[] dst, int dstIndex)
  57. {
  58. int start = dstIndex;
  59. WriteTime(_createTime, dst, dstIndex);
  60. dstIndex += 8;
  61. WriteInt8(0L, dst, dstIndex);
  62. dstIndex += 8;
  63. WriteTime(_lastWriteTime, dst, dstIndex);
  64. dstIndex += 8;
  65. WriteInt8(0L, dst, dstIndex);
  66. dstIndex += 8;
  67. WriteInt2(unchecked(0x80) | _attributes, dst, dstIndex);
  68. dstIndex += 2;
  69. WriteInt8(0L, dst, dstIndex);
  70. dstIndex += 6;
  71. return dstIndex - start;
  72. }
  73. internal override int ReadSetupWireFormat(byte[] buffer, int bufferIndex, int len
  74. )
  75. {
  76. return 0;
  77. }
  78. internal override int ReadParametersWireFormat(byte[] buffer, int bufferIndex, int
  79. len)
  80. {
  81. return 0;
  82. }
  83. internal override int ReadDataWireFormat(byte[] buffer, int bufferIndex, int len)
  84. {
  85. return 0;
  86. }
  87. public override string ToString()
  88. {
  89. return "Trans2SetFileInformation[" + base.ToString() + ",fid=" + _fid +
  90. "]";
  91. }
  92. }
  93. }