Browse Source
Merge pull request #3801 from abpframework/liangshiwei/virtual-file-system
make virtual file system return the root directory
pull/3840/head
Halil İbrahim Kalkan
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
26 additions and
5 deletions
-
framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/DictionaryBasedFileProvider.cs
-
framework/src/Volo.Abp.VirtualFileSystem/Volo/Abp/VirtualFileSystem/VirtualFilePathHelper.cs
-
framework/test/Volo.Abp.VirtualFileSystem.Tests/Volo/Abp/VirtualFileSystem/VirtualFileProvider_Tests.cs
|
|
|
@ -11,7 +11,7 @@ namespace Volo.Abp.VirtualFileSystem |
|
|
|
|
|
|
|
public virtual IFileInfo GetFileInfo(string subpath) |
|
|
|
{ |
|
|
|
if (string.IsNullOrEmpty(subpath)) |
|
|
|
if (subpath == null) |
|
|
|
{ |
|
|
|
return new NotFoundFileInfo(subpath); |
|
|
|
} |
|
|
|
@ -67,4 +67,4 @@ namespace Volo.Abp.VirtualFileSystem |
|
|
|
return subpath; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -10,6 +10,11 @@ namespace Volo.Abp.VirtualFileSystem |
|
|
|
|
|
|
|
public static string NormalizePath(string fullPath) |
|
|
|
{ |
|
|
|
if (fullPath.Equals("/", StringComparison.Ordinal)) |
|
|
|
{ |
|
|
|
return string.Empty; |
|
|
|
} |
|
|
|
|
|
|
|
var fileName = fullPath; |
|
|
|
var extension = ""; |
|
|
|
|
|
|
|
@ -29,7 +34,7 @@ namespace Volo.Abp.VirtualFileSystem |
|
|
|
|
|
|
|
return NormalizeChars(fileName) + extension; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static string NormalizeChars(string fileName) |
|
|
|
{ |
|
|
|
var folderParts = fileName.Replace(".", "/").Split("/"); |
|
|
|
@ -42,4 +47,4 @@ namespace Volo.Abp.VirtualFileSystem |
|
|
|
return folderParts.Take(folderParts.Length - 1).Select(s => s.Replace("-", "_")).JoinAsString("/") + "/" + folderParts.Last(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -1,4 +1,5 @@ |
|
|
|
using System.IO; |
|
|
|
using System; |
|
|
|
using System.IO; |
|
|
|
using System.Linq; |
|
|
|
using System.Text; |
|
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
@ -47,6 +48,21 @@ namespace Volo.Abp.VirtualFileSystem |
|
|
|
contentList.ShouldContain(x => x.Name == "jquery-3-1-1-min.js"); |
|
|
|
} |
|
|
|
|
|
|
|
[Theory] |
|
|
|
[InlineData("/")] |
|
|
|
[InlineData("")] |
|
|
|
public void Should_Define_And_Get_Embedded_Root_Directory_Contents(string path) |
|
|
|
{ |
|
|
|
//Act
|
|
|
|
var contents = _virtualFileProvider.GetDirectoryContents(path); |
|
|
|
|
|
|
|
//Assert
|
|
|
|
contents.Exists.ShouldNotBeNull(); |
|
|
|
|
|
|
|
var contentList = contents.ToList(); |
|
|
|
contentList.ShouldContain(x => x.Name == "js"); |
|
|
|
} |
|
|
|
|
|
|
|
[DependsOn(typeof(AbpVirtualFileSystemModule))] |
|
|
|
public class TestModule : AbpModule |
|
|
|
{ |
|
|
|
|