mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-07-25 18:38:14 +02:00
SMB1: Minor optimization of GetFindInformationList
This commit is contained in:
parent
4f28519223
commit
6c08f23751
1 changed files with 8 additions and 3 deletions
|
@ -50,13 +50,18 @@ namespace SMBLibrary.Server.SMB1
|
||||||
public static FindInformationList GetFindInformationList(List<QueryDirectoryFileInformation> entries, FindInformationLevel informationLevel, bool isUnicode, bool returnResumeKeys, int maxLength)
|
public static FindInformationList GetFindInformationList(List<QueryDirectoryFileInformation> entries, FindInformationLevel informationLevel, bool isUnicode, bool returnResumeKeys, int maxLength)
|
||||||
{
|
{
|
||||||
FindInformationList result = new FindInformationList();
|
FindInformationList result = new FindInformationList();
|
||||||
|
int pageLength = 0;
|
||||||
for (int index = 0; index < entries.Count; index++)
|
for (int index = 0; index < entries.Count; index++)
|
||||||
{
|
{
|
||||||
FindInformation infoEntry = GetFindInformation(entries[index], informationLevel, isUnicode, returnResumeKeys);
|
FindInformation infoEntry = GetFindInformation(entries[index], informationLevel, isUnicode, returnResumeKeys);
|
||||||
result.Add(infoEntry);
|
int entryLength = infoEntry.GetLength(isUnicode);
|
||||||
if (result.GetLength(isUnicode) > maxLength)
|
if (pageLength + entryLength <= maxLength)
|
||||||
|
{
|
||||||
|
result.Add(infoEntry);
|
||||||
|
pageLength += entryLength;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
result.RemoveAt(result.Count - 1);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue