SmbComQueryInformationResponse.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. using SharpCifs.Util;
  18. using SharpCifs.Util.Sharpen;
  19. namespace SharpCifs.Smb
  20. {
  21. internal class SmbComQueryInformationResponse : ServerMessageBlock, IInfo
  22. {
  23. private int _fileAttributes = 0x0000;
  24. private long _lastWriteTime;
  25. private long _serverTimeZoneOffset;
  26. private int _fileSize;
  27. internal SmbComQueryInformationResponse(long serverTimeZoneOffset)
  28. {
  29. this._serverTimeZoneOffset = serverTimeZoneOffset;
  30. Command = SmbComQueryInformation;
  31. }
  32. public virtual int GetAttributes()
  33. {
  34. return _fileAttributes;
  35. }
  36. public virtual long GetCreateTime()
  37. {
  38. return _lastWriteTime + _serverTimeZoneOffset;
  39. }
  40. public virtual long GetLastWriteTime()
  41. {
  42. return _lastWriteTime + _serverTimeZoneOffset;
  43. }
  44. public virtual long GetSize()
  45. {
  46. return _fileSize;
  47. }
  48. internal override int WriteParameterWordsWireFormat(byte[] dst, int dstIndex)
  49. {
  50. return 0;
  51. }
  52. internal override int WriteBytesWireFormat(byte[] dst, int dstIndex)
  53. {
  54. return 0;
  55. }
  56. internal override int ReadParameterWordsWireFormat(byte[] buffer, int bufferIndex
  57. )
  58. {
  59. if (WordCount == 0)
  60. {
  61. return 0;
  62. }
  63. _fileAttributes = ReadInt2(buffer, bufferIndex);
  64. bufferIndex += 2;
  65. _lastWriteTime = ReadUTime(buffer, bufferIndex);
  66. bufferIndex += 4;
  67. _fileSize = ReadInt4(buffer, bufferIndex);
  68. return 20;
  69. }
  70. internal override int ReadBytesWireFormat(byte[] buffer, int bufferIndex)
  71. {
  72. return 0;
  73. }
  74. public override string ToString()
  75. {
  76. return "SmbComQueryInformationResponse[" + base.ToString() + ",fileAttributes=0x"
  77. + Hexdump.ToHexString(_fileAttributes, 4) + ",lastWriteTime=" + Extensions.CreateDate
  78. (_lastWriteTime) + ",fileSize=" + _fileSize + "]";
  79. }
  80. }
  81. }