Open by path
This commit is contained in:
@@ -46,6 +46,22 @@ public sealed partial class LocalContentProvider : ContentProviderBase, ILocalCo
|
||||
});
|
||||
}
|
||||
|
||||
public override bool CanHandlePath(NativePath path)
|
||||
{
|
||||
var rootDrive = _rootDirectories
|
||||
.Items
|
||||
.FirstOrDefault(r =>
|
||||
path.Path.StartsWith(
|
||||
GetNativePath(r.Path).Path,
|
||||
_isCaseInsensitive
|
||||
? StringComparison.InvariantCultureIgnoreCase
|
||||
: StringComparison.InvariantCulture
|
||||
)
|
||||
);
|
||||
|
||||
return rootDrive is not null;
|
||||
}
|
||||
|
||||
public override Task<IItem> GetItemByNativePathAsync(NativePath nativePath,
|
||||
PointInTime pointInTime,
|
||||
bool forceResolve = false,
|
||||
@@ -58,11 +74,11 @@ public sealed partial class LocalContentProvider : ContentProviderBase, ILocalCo
|
||||
{
|
||||
if ((path?.Length ?? 0) == 0)
|
||||
{
|
||||
return Task.FromResult((IItem)this);
|
||||
return Task.FromResult((IItem) this);
|
||||
}
|
||||
else if (Directory.Exists(path))
|
||||
{
|
||||
return Task.FromResult((IItem)DirectoryToContainer(
|
||||
return Task.FromResult((IItem) DirectoryToContainer(
|
||||
new DirectoryInfo(path!.TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar),
|
||||
pointInTime,
|
||||
!itemInitializationSettings.SkipChildInitialization)
|
||||
@@ -70,7 +86,7 @@ public sealed partial class LocalContentProvider : ContentProviderBase, ILocalCo
|
||||
}
|
||||
else if (File.Exists(path))
|
||||
{
|
||||
return Task.FromResult((IItem)FileToElement(new FileInfo(path), pointInTime));
|
||||
return Task.FromResult((IItem) FileToElement(new FileInfo(path), pointInTime));
|
||||
}
|
||||
|
||||
var type = forceResolvePathType switch
|
||||
@@ -102,10 +118,10 @@ public sealed partial class LocalContentProvider : ContentProviderBase, ILocalCo
|
||||
return forceResolvePathType switch
|
||||
{
|
||||
AbsolutePathType.Container => Task.FromResult(
|
||||
(IItem)CreateEmptyContainer(
|
||||
(IItem) CreateEmptyContainer(
|
||||
nativePath,
|
||||
pointInTime,
|
||||
Observable.Return(new List<Exception>() { innerException })
|
||||
Observable.Return(new List<Exception>() {innerException})
|
||||
)
|
||||
),
|
||||
AbsolutePathType.Element => Task.FromResult(CreateEmptyElement(nativePath)),
|
||||
@@ -220,7 +236,7 @@ public sealed partial class LocalContentProvider : ContentProviderBase, ILocalCo
|
||||
SourceCache<AbsolutePath, string>? result = null;
|
||||
try
|
||||
{
|
||||
var items = initializeChildren ? (List<AbsolutePath>?)GetItemsByContainer(directoryInfo, pointInTime) : null;
|
||||
var items = initializeChildren ? (List<AbsolutePath>?) GetItemsByContainer(directoryInfo, pointInTime) : null;
|
||||
if (items != null)
|
||||
{
|
||||
result = new SourceCache<AbsolutePath, string>(i => i.Path.Path);
|
||||
@@ -229,7 +245,7 @@ public sealed partial class LocalContentProvider : ContentProviderBase, ILocalCo
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
exceptions.OnNext(new List<Exception>() { e });
|
||||
exceptions.OnNext(new List<Exception>() {e});
|
||||
}
|
||||
|
||||
return Task.FromResult(result?.Connect());
|
||||
@@ -303,7 +319,7 @@ public sealed partial class LocalContentProvider : ContentProviderBase, ILocalCo
|
||||
var size = maxLength ?? realFileSize switch
|
||||
{
|
||||
> int.MaxValue => int.MaxValue,
|
||||
_ => (int)realFileSize
|
||||
_ => (int) realFileSize
|
||||
};
|
||||
var buffer = new byte[size];
|
||||
await reader.ReadAsync(buffer, 0, size);
|
||||
|
||||
Reference in New Issue
Block a user