2020-03-08 09:00:02 +01:00
|
|
|
|
using LibHac.Common;
|
|
|
|
|
using LibHac.Fs;
|
2020-01-28 08:55:39 +01:00
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
|
|
namespace LibHac.Tests.Fs.IFileSystemTestBase
|
|
|
|
|
{
|
|
|
|
|
public abstract partial class IFileSystemTests
|
|
|
|
|
{
|
|
|
|
|
[Fact]
|
|
|
|
|
public void CleanDirectoryRecursively_DeletesChildren()
|
|
|
|
|
{
|
|
|
|
|
IFileSystem fs = CreateFileSystem();
|
|
|
|
|
|
2020-03-08 09:00:02 +01:00
|
|
|
|
fs.CreateDirectory("/dir".ToU8Span());
|
|
|
|
|
fs.CreateDirectory("/dir/dir2".ToU8Span());
|
|
|
|
|
fs.CreateFile("/dir/file1".ToU8Span(), 0, CreateFileOptions.None);
|
2020-01-28 08:55:39 +01:00
|
|
|
|
|
2020-03-08 09:00:02 +01:00
|
|
|
|
Result rcDelete = fs.CleanDirectoryRecursively("/dir".ToU8Span());
|
2020-01-28 08:55:39 +01:00
|
|
|
|
|
2020-03-08 09:00:02 +01:00
|
|
|
|
Result rcDir1Type = fs.GetEntryType(out DirectoryEntryType dir1Type, "/dir".ToU8Span());
|
|
|
|
|
Result rcDir2Type = fs.GetEntryType(out _, "/dir/dir2".ToU8Span());
|
|
|
|
|
Result rcFileType = fs.GetEntryType(out _, "/dir/file1".ToU8Span());
|
2020-01-28 08:55:39 +01:00
|
|
|
|
|
|
|
|
|
Assert.True(rcDelete.IsSuccess());
|
|
|
|
|
|
|
|
|
|
Assert.True(rcDir1Type.IsSuccess());
|
|
|
|
|
Assert.Equal(DirectoryEntryType.Directory, dir1Type);
|
|
|
|
|
|
|
|
|
|
Assert.Equal(ResultFs.PathNotFound.Value, rcDir2Type);
|
|
|
|
|
Assert.Equal(ResultFs.PathNotFound.Value, rcFileType);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|