2021-07-19 22:16:11 +02:00
|
|
|
|
using LibHac.Fs;
|
2020-06-10 07:55:59 +02:00
|
|
|
|
using LibHac.Fs.Fsa;
|
2020-01-28 08:55:39 +01:00
|
|
|
|
using Xunit;
|
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
namespace LibHac.Tests.Fs.IFileSystemTestBase;
|
|
|
|
|
|
|
|
|
|
public abstract partial class IFileSystemTests
|
2020-01-28 08:55:39 +01:00
|
|
|
|
{
|
2021-11-14 20:08:57 +01:00
|
|
|
|
[Fact]
|
|
|
|
|
public void CleanDirectoryRecursively_DeletesChildren()
|
2020-01-28 08:55:39 +01:00
|
|
|
|
{
|
2021-11-14 20:08:57 +01:00
|
|
|
|
IFileSystem fs = CreateFileSystem();
|
2020-01-28 08:55:39 +01:00
|
|
|
|
|
2021-11-14 20:08:57 +01:00
|
|
|
|
fs.CreateDirectory("/dir");
|
|
|
|
|
fs.CreateDirectory("/dir/dir2");
|
|
|
|
|
fs.CreateFile("/dir/file1", 0, CreateFileOptions.None);
|
2020-01-28 08:55:39 +01:00
|
|
|
|
|
2022-11-10 05:33:27 +01:00
|
|
|
|
Result resultDelete = fs.CleanDirectoryRecursively("/dir");
|
2020-01-28 08:55:39 +01:00
|
|
|
|
|
2022-11-10 05:33:27 +01:00
|
|
|
|
Result resultDir1Type = fs.GetEntryType(out DirectoryEntryType dir1Type, "/dir");
|
|
|
|
|
Result resultDir2Type = fs.GetEntryType(out _, "/dir/dir2");
|
|
|
|
|
Result resultFileType = fs.GetEntryType(out _, "/dir/file1");
|
2020-01-28 08:55:39 +01:00
|
|
|
|
|
2022-11-10 05:33:27 +01:00
|
|
|
|
Assert.Success(resultDelete);
|
2020-01-28 08:55:39 +01:00
|
|
|
|
|
2022-11-10 05:33:27 +01:00
|
|
|
|
Assert.Success(resultDir1Type);
|
2021-11-14 20:08:57 +01:00
|
|
|
|
Assert.Equal(DirectoryEntryType.Directory, dir1Type);
|
2020-01-28 08:55:39 +01:00
|
|
|
|
|
2022-11-10 05:33:27 +01:00
|
|
|
|
Assert.Result(ResultFs.PathNotFound, resultDir2Type);
|
|
|
|
|
Assert.Result(ResultFs.PathNotFound, resultFileType);
|
2020-01-28 08:55:39 +01:00
|
|
|
|
}
|
2022-11-12 02:21:07 +01:00
|
|
|
|
}
|