1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- /* Copyright (C) 2014 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
- *
- * You can redistribute this program and/or modify it under the terms of
- * the GNU Lesser Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- */
- using System;
- using System.Collections.Generic;
- using System.Text;
- using Utilities;
- namespace SMBLibrary.SMB1
- {
- /// <summary>
- /// SMB_FEA_LIST
- /// </summary>
- public class FullExtendedAttributeList : List<FullExtendedAttribute>
- {
- public FullExtendedAttributeList()
- {
- }
- public FullExtendedAttributeList(byte[] buffer) : this(buffer, 0)
- {
- }
- public FullExtendedAttributeList(byte[] buffer, ref int offset) : this(buffer, offset)
- {
- // length MUST contain the total size of the FEAList field, plus the size of the SizeOfListInBytes field
- int length = (int)LittleEndianConverter.ToUInt32(buffer, offset);
- offset += length;
- }
- public FullExtendedAttributeList(byte[] buffer, int offset)
- {
- // length MUST contain the total size of the FEAList field, plus the size of the SizeOfListInBytes field
- int length = (int)LittleEndianConverter.ToUInt32(buffer, offset);
- int position = offset + 4;
- int eof = offset + length;
- while (position < eof)
- {
- FullExtendedAttribute attribute = new FullExtendedAttribute(buffer, position);
- this.Add(attribute);
- position += attribute.Length;
- }
- }
- public byte[] GetBytes()
- {
- byte[] buffer = new byte[this.Length];
- WriteBytes(buffer, 0);
- return buffer;
- }
- public void WriteBytes(byte[] buffer, ref int offset)
- {
- WriteBytes(buffer, offset);
- offset += this.Length;
- }
- public void WriteBytes(byte[] buffer, int offset)
- {
- foreach (FullExtendedAttribute entry in this)
- {
- entry.WriteBytes(buffer, offset);
- offset += entry.Length;
- }
- }
- public int Length
- {
- get
- {
- int length = 0;
- foreach (FullExtendedAttribute entry in this)
- {
- length += entry.Length;
- }
- return length;
- }
- }
- }
- }
|