mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-23 00:43:00 -05:00
tst: passthrough-dotnet: testing
This commit is contained in:
parent
f2d98bbf25
commit
67711082b0
@ -458,8 +458,8 @@ namespace Fsp
|
|||||||
UInt32 Length,
|
UInt32 Length,
|
||||||
out UInt32 PBytesTransferred)
|
out UInt32 PBytesTransferred)
|
||||||
{
|
{
|
||||||
PBytesTransferred = default(UInt32);
|
return SeekableReadDirectory(FileNode, FileDesc, Pattern, Marker, Buffer, Length,
|
||||||
return STATUS_INVALID_DEVICE_REQUEST;
|
out PBytesTransferred);
|
||||||
}
|
}
|
||||||
protected virtual Boolean ReadDirectoryEntry(
|
protected virtual Boolean ReadDirectoryEntry(
|
||||||
Object FileNode,
|
Object FileNode,
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Security.AccessControl;
|
using System.Security.AccessControl;
|
||||||
@ -48,7 +48,7 @@ namespace passthrough
|
|||||||
{
|
{
|
||||||
public FileStream Stream;
|
public FileStream Stream;
|
||||||
public DirectoryInfo DirInfo;
|
public DirectoryInfo DirInfo;
|
||||||
public DirectoryBuffer DirBuffer;
|
public DictionaryEntry[] FileSystemInfos;
|
||||||
|
|
||||||
public FileDesc(FileStream Stream)
|
public FileDesc(FileStream Stream)
|
||||||
{
|
{
|
||||||
@ -236,6 +236,18 @@ namespace passthrough
|
|||||||
UInt32 dwBufferSize);
|
UInt32 dwBufferSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class DirectoryEntryComparer : IComparer
|
||||||
|
{
|
||||||
|
public int Compare(object x, object y)
|
||||||
|
{
|
||||||
|
return String.Compare(
|
||||||
|
(String)((DictionaryEntry)x).Key,
|
||||||
|
(String)((DictionaryEntry)y).Key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static DirectoryEntryComparer _DirectoryEntryComparer =
|
||||||
|
new DirectoryEntryComparer();
|
||||||
|
|
||||||
public Ptfs() : base()
|
public Ptfs() : base()
|
||||||
{
|
{
|
||||||
SetSectorSize(ALLOCATION_UNIT);
|
SetSectorSize(ALLOCATION_UNIT);
|
||||||
@ -438,8 +450,6 @@ namespace passthrough
|
|||||||
FileDesc FileDesc = (FileDesc)FileDesc0;
|
FileDesc FileDesc = (FileDesc)FileDesc0;
|
||||||
if (null != FileDesc.Stream)
|
if (null != FileDesc.Stream)
|
||||||
FileDesc.Stream.Dispose();
|
FileDesc.Stream.Dispose();
|
||||||
if (null != FileDesc.DirBuffer)
|
|
||||||
FileDesc.DirBuffer.Dispose();
|
|
||||||
}
|
}
|
||||||
protected override Int32 Read(
|
protected override Int32 Read(
|
||||||
Object FileNode,
|
Object FileNode,
|
||||||
@ -597,21 +607,6 @@ namespace passthrough
|
|||||||
FileDesc.SetSecurityDescriptor(Sections, SecurityDescriptor);
|
FileDesc.SetSecurityDescriptor(Sections, SecurityDescriptor);
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
protected override Int32 ReadDirectory(
|
|
||||||
Object FileNode,
|
|
||||||
Object FileDesc0,
|
|
||||||
String Pattern,
|
|
||||||
String Marker,
|
|
||||||
IntPtr Buffer,
|
|
||||||
UInt32 Length,
|
|
||||||
out UInt32 PBytesTransferred)
|
|
||||||
{
|
|
||||||
FileDesc FileDesc = (FileDesc)FileDesc0;
|
|
||||||
if (null == FileDesc.DirBuffer)
|
|
||||||
FileDesc.DirBuffer = new DirectoryBuffer();
|
|
||||||
return BufferedReadDirectory(FileDesc.DirBuffer,
|
|
||||||
FileNode, FileDesc, Pattern, Marker, Buffer, Length, out PBytesTransferred);
|
|
||||||
}
|
|
||||||
protected override Boolean ReadDirectoryEntry(
|
protected override Boolean ReadDirectoryEntry(
|
||||||
Object FileNode,
|
Object FileNode,
|
||||||
Object FileDesc0,
|
Object FileDesc0,
|
||||||
@ -621,18 +616,43 @@ namespace passthrough
|
|||||||
out String FileName,
|
out String FileName,
|
||||||
out FileInfo FileInfo)
|
out FileInfo FileInfo)
|
||||||
{
|
{
|
||||||
|
FileDesc FileDesc = (FileDesc)FileDesc0;
|
||||||
|
if (null == FileDesc.FileSystemInfos)
|
||||||
|
{
|
||||||
|
IEnumerable Enum = FileDesc.DirInfo.EnumerateFileSystemInfos(
|
||||||
|
null != Pattern ? Pattern : "*");
|
||||||
|
SortedList List = new SortedList();
|
||||||
|
List.Add(".", FileDesc.DirInfo);
|
||||||
|
List.Add("..", FileDesc.DirInfo.Parent);
|
||||||
|
foreach (FileSystemInfo Info in Enum)
|
||||||
|
List.Add(Info.Name, Info);
|
||||||
|
FileDesc.FileSystemInfos = new DictionaryEntry[List.Count];
|
||||||
|
List.CopyTo(FileDesc.FileSystemInfos, 0);
|
||||||
|
}
|
||||||
|
int Index;
|
||||||
if (null == Context)
|
if (null == Context)
|
||||||
{
|
{
|
||||||
FileDesc FileDesc = (FileDesc)FileDesc0;
|
Index = 0;
|
||||||
if (null == Pattern)
|
if (null != Marker)
|
||||||
Pattern = "*";
|
|
||||||
Context = FileDesc.DirInfo.EnumerateFileSystemInfos(Pattern).GetEnumerator();
|
|
||||||
}
|
|
||||||
IEnumerator<FileSystemInfo> InfoEnumerator = (IEnumerator<FileSystemInfo>)Context;
|
|
||||||
if (InfoEnumerator.MoveNext())
|
|
||||||
{
|
{
|
||||||
FileName = InfoEnumerator.Current.Name;
|
Index = Array.BinarySearch(FileDesc.FileSystemInfos,
|
||||||
FileDesc.GetFileInfoFromFileSystemInfo(InfoEnumerator.Current, out FileInfo);
|
new DictionaryEntry(Marker, null),
|
||||||
|
_DirectoryEntryComparer);
|
||||||
|
if (0 <= Index)
|
||||||
|
Index++;
|
||||||
|
else
|
||||||
|
Index = ~Index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Index = (int)Context;
|
||||||
|
if (FileDesc.FileSystemInfos.Length > Index)
|
||||||
|
{
|
||||||
|
Context = Index + 1;
|
||||||
|
FileName = (String)FileDesc.FileSystemInfos[Index].Key;
|
||||||
|
FileDesc.GetFileInfoFromFileSystemInfo(
|
||||||
|
(FileSystemInfo)FileDesc.FileSystemInfos[Index].Value,
|
||||||
|
out FileInfo);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user