2020-02-10 22:06:00 +01:00
|
|
|
|
using LibHac.Common;
|
2020-02-03 08:44:50 +01:00
|
|
|
|
using LibHac.Fs;
|
2020-06-10 07:55:59 +02:00
|
|
|
|
using LibHac.Fs.Fsa;
|
2020-02-03 08:44:50 +01:00
|
|
|
|
using LibHac.FsSystem;
|
|
|
|
|
using LibHac.Tests.Fs.IFileSystemTestBase;
|
2020-02-10 22:06:00 +01:00
|
|
|
|
using Xunit;
|
2020-02-03 08:44:50 +01:00
|
|
|
|
|
|
|
|
|
namespace LibHac.Tests.Fs
|
|
|
|
|
{
|
|
|
|
|
public class SubdirectoryFileSystemTests : IFileSystemTests
|
|
|
|
|
{
|
|
|
|
|
protected override IFileSystem CreateFileSystem()
|
|
|
|
|
{
|
2020-02-10 22:06:00 +01:00
|
|
|
|
return CreateFileSystemInternal().subDirFs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private (IFileSystem baseFs, IFileSystem subDirFs) CreateFileSystemInternal()
|
|
|
|
|
{
|
2020-02-03 08:44:50 +01:00
|
|
|
|
var baseFs = new InMemoryFileSystem();
|
2020-03-08 09:00:02 +01:00
|
|
|
|
baseFs.CreateDirectory("/sub".ToU8Span());
|
|
|
|
|
baseFs.CreateDirectory("/sub/path".ToU8Span());
|
2020-02-03 08:44:50 +01:00
|
|
|
|
|
2020-02-10 22:06:00 +01:00
|
|
|
|
SubdirectoryFileSystem.CreateNew(out SubdirectoryFileSystem subFs, baseFs, "/sub/path".ToU8String()).ThrowIfFailure();
|
|
|
|
|
return (baseFs, subFs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void CreateFile_CreatedInBaseFileSystem()
|
|
|
|
|
{
|
|
|
|
|
(IFileSystem baseFs, IFileSystem subDirFs) = CreateFileSystemInternal();
|
|
|
|
|
|
2020-03-08 09:00:02 +01:00
|
|
|
|
subDirFs.CreateFile("/file".ToU8Span(), 0, CreateFileOptions.None);
|
2020-02-03 08:44:50 +01:00
|
|
|
|
|
2020-07-06 17:37:34 +02:00
|
|
|
|
Assert.Success(baseFs.GetEntryType(out DirectoryEntryType type, "/sub/path/file".ToU8Span()));
|
2020-02-10 22:06:00 +01:00
|
|
|
|
Assert.Equal(DirectoryEntryType.File, type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void CreateDirectory_CreatedInBaseFileSystem()
|
|
|
|
|
{
|
|
|
|
|
(IFileSystem baseFs, IFileSystem subDirFs) = CreateFileSystemInternal();
|
|
|
|
|
|
2020-03-08 09:00:02 +01:00
|
|
|
|
subDirFs.CreateDirectory("/dir".ToU8Span());
|
2020-02-10 22:06:00 +01:00
|
|
|
|
|
2020-07-06 17:37:34 +02:00
|
|
|
|
Assert.Success(baseFs.GetEntryType(out DirectoryEntryType type, "/sub/path/dir".ToU8Span()));
|
2020-02-10 22:06:00 +01:00
|
|
|
|
Assert.Equal(DirectoryEntryType.Directory, type);
|
2020-02-03 08:44:50 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-02-10 22:06:00 +01:00
|
|
|
|
|
2020-02-03 08:44:50 +01:00
|
|
|
|
public class SubdirectoryFileSystemTestsRoot : IFileSystemTests
|
|
|
|
|
{
|
|
|
|
|
protected override IFileSystem CreateFileSystem()
|
|
|
|
|
{
|
|
|
|
|
var baseFs = new InMemoryFileSystem();
|
|
|
|
|
|
2020-02-10 22:06:00 +01:00
|
|
|
|
SubdirectoryFileSystem.CreateNew(out SubdirectoryFileSystem subFs, baseFs, "/".ToU8String()).ThrowIfFailure();
|
2020-02-03 08:44:50 +01:00
|
|
|
|
return subFs;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|