diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
index 8c7c3c6..bd394e6 100644
--- a/.github/workflows/docker.yml
+++ b/.github/workflows/docker.yml
@@ -2,10 +2,6 @@ name: Docker Build
on:
push:
- branches:
- - master
- - main
- - codex/**
pull_request:
jobs:
diff --git a/VirtualFS.Tests/Physical/SimpleFtpFileSystemTests.cs b/VirtualFS.Tests/Physical/SimpleFtpFileSystemTests.cs
new file mode 100644
index 0000000..0d111e0
--- /dev/null
+++ b/VirtualFS.Tests/Physical/SimpleFtpFileSystemTests.cs
@@ -0,0 +1,23 @@
+using System.IO;
+using VirtualFS.Physical;
+
+namespace VirtualFS.Tests.Physical;
+
+public class SimpleFtpFileSystemTests
+{
+ [Fact]
+ public void DirectoryListingContainsEntryReturnsFalseWhenNameIsMissing()
+ {
+ using var reader = new StringReader("alpha\nbeta\ngamma\n");
+
+ Assert.False(SimpleFtpFileSystem.DirectoryListingContainsEntry(reader, "delta"));
+ }
+
+ [Fact]
+ public void DirectoryListingContainsEntrySkipsDotEntries()
+ {
+ using var reader = new StringReader(".\n..\ntarget\n");
+
+ Assert.True(SimpleFtpFileSystem.DirectoryListingContainsEntry(reader, "target"));
+ }
+}
diff --git a/VirtualFS/Physical/FtpFileSystem.cs b/VirtualFS/Physical/FtpFileSystem.cs
index a5b3af6..767ac7f 100644
--- a/VirtualFS/Physical/FtpFileSystem.cs
+++ b/VirtualFS/Physical/FtpFileSystem.cs
@@ -185,6 +185,39 @@ namespace VirtualFS.Physical
LastAccessTime = item.Modified,
});
break;
+
+ case FtpObjectType.Link:
+ if (item.LinkObject != null)
+ {
+ switch (item.LinkObject.Type)
+ {
+ case FtpObjectType.File:
+ result.Add(new File()
+ {
+ IsReadOnly = IsReadOnly,
+ Path = path + item.Name,
+ FileSystem = this,
+ CreationTime = item.LinkObject.Created,
+ LastWriteTime = item.LinkObject.Modified,
+ LastAccessTime = item.LinkObject.Modified,
+ Size = item.LinkObject.Size,
+ });
+ break;
+
+ case FtpObjectType.Directory:
+ result.Add(new Directory()
+ {
+ IsReadOnly = IsReadOnly,
+ Path = string.Concat(path, item.Name.TrimEnd('/'), "/"),
+ FileSystem = this,
+ CreationTime = item.LinkObject.Created,
+ LastWriteTime = item.LinkObject.Modified,
+ LastAccessTime = item.LinkObject.Modified,
+ });
+ break;
+ }
+ }
+ break;
}
}
}
@@ -226,7 +259,10 @@ namespace VirtualFS.Physical
base.DirectoryDelete(path, recursive);
using (FtpClient conn = GetConnection())
- conn.DeleteDirectory(GetFtpPath(path));
+ if (recursive)
+ conn.DeleteDirectory(GetFtpPath(path), FtpListOption.Recursive);
+ else
+ conn.DeleteDirectory(GetFtpPath(path));
}
/// Opens an existing file for reading.
diff --git a/VirtualFS/Physical/SimpleFtpFileSystem.cs b/VirtualFS/Physical/SimpleFtpFileSystem.cs
index 8124df5..a13c0a9 100644
--- a/VirtualFS/Physical/SimpleFtpFileSystem.cs
+++ b/VirtualFS/Physical/SimpleFtpFileSystem.cs
@@ -86,24 +86,7 @@ namespace VirtualFS.Physical
FtpDoStuff(WebRequestMethods.Ftp.ListDirectory, path, null, r =>
{
using (StreamReader sr = new StreamReader(r.GetResponseStream()))
- {
- string str = sr.ReadLine();
- while (str != null)
- {
- if (string.IsNullOrEmpty(str) || str == "." || str == "..")
- {
- str = sr.ReadLine();
- continue;
- }
-
- if (str == path.Name)
- {
- res = true;
- sr.ReadToEnd();
- return;
- }
- }
- }
+ res = DirectoryListingContainsEntry(sr, path.Name);
});
return res;
@@ -245,6 +228,17 @@ namespace VirtualFS.Physical
{
base.DirectoryDelete(path, recursive);
+ if (recursive)
+ {
+ foreach (var entry in GetEntries(path))
+ {
+ if (entry.IsDirectory)
+ DirectoryDelete(entry.Path, recursive: true);
+ else
+ FileDelete(entry.Path);
+ }
+ }
+
FtpDoStuff(WebRequestMethods.Ftp.RemoveDirectory, path);
}
@@ -373,6 +367,21 @@ namespace VirtualFS.Physical
return resp.StatusCode;
}
}
+
+ internal static bool DirectoryListingContainsEntry(TextReader reader, string name)
+ {
+ string line = reader.ReadLine();
+
+ while (line != null)
+ {
+ if (!string.IsNullOrEmpty(line) && line != "." && line != ".." && line == name)
+ return true;
+
+ line = reader.ReadLine();
+ }
+
+ return false;
+ }
}
#pragma warning restore SYSLIB0014
}
diff --git a/VirtualFS/VirtualFS.csproj b/VirtualFS/VirtualFS.csproj
index 04bcb18..e02ff43 100644
--- a/VirtualFS/VirtualFS.csproj
+++ b/VirtualFS/VirtualFS.csproj
@@ -27,4 +27,10 @@
+
+
+ <_Parameter1>VirtualFS.Tests
+
+
+