diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
new file mode 100644
index 0000000..8c7c3c6
--- /dev/null
+++ b/.github/workflows/docker.yml
@@ -0,0 +1,20 @@
+name: Docker Build
+
+on:
+ push:
+ branches:
+ - master
+ - main
+ - codex/**
+ pull_request:
+
+jobs:
+ docker-test:
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Build test image
+ run: docker build --target test -t virtualfs:test .
diff --git a/VirtualFS.Tests/VirtualFS.Tests.csproj b/VirtualFS.Tests/VirtualFS.Tests.csproj
index be155d6..9eee948 100644
--- a/VirtualFS.Tests/VirtualFS.Tests.csproj
+++ b/VirtualFS.Tests/VirtualFS.Tests.csproj
@@ -8,6 +8,7 @@
false
true
true
+ $(NoWarn);MTP0001
diff --git a/VirtualFS/EmbeddedResource/EmbeddedResourceFileSystem.cs b/VirtualFS/EmbeddedResource/EmbeddedResourceFileSystem.cs
index 4226b96..31692eb 100644
--- a/VirtualFS/EmbeddedResource/EmbeddedResourceFileSystem.cs
+++ b/VirtualFS/EmbeddedResource/EmbeddedResourceFileSystem.cs
@@ -46,6 +46,16 @@ namespace VirtualFS.EmbeddedResource
/// Gets the assembly on which file system operates.
public Assembly Assembly { get; private set; }
+ private string AssemblyLocation
+ {
+ get { return string.IsNullOrEmpty(Assembly.Location) ? null : Assembly.Location; }
+ }
+
+ private DateTime AssemblyTimestamp(Func selector)
+ {
+ return string.IsNullOrEmpty(AssemblyLocation) ? DateTime.UtcNow : selector(new System.IO.FileInfo(AssemblyLocation));
+ }
+
/// Initializes a new instance of the class.
/// The assembly.
/// The root namespace.
@@ -55,8 +65,6 @@ namespace VirtualFS.EmbeddedResource
{
Assembly = assembly;
- var fi = new System.IO.FileInfo(Uri.UnescapeDataString(new UriBuilder(Assembly.CodeBase).Path));
-
_pathToResource = Assembly.GetManifestResourceNames()
.Where(x => (string.IsNullOrEmpty(rootNamespace) || x.StartsWith(rootNamespace)) && (filter == null || filter.IsMatch(x)))
.Select(x => new File()
@@ -65,9 +73,9 @@ namespace VirtualFS.EmbeddedResource
IsReadOnly = IsReadOnly,
Path = ResourceToPath(rootNamespace, x),
FileSystem = this,
- CreationTime = fi.CreationTimeUtc,
- LastAccessTime = fi.LastAccessTime,
- LastWriteTime = fi.LastWriteTime,
+ CreationTime = AssemblyTimestamp(fi => fi.CreationTimeUtc),
+ LastAccessTime = AssemblyTimestamp(fi => fi.LastAccessTimeUtc),
+ LastWriteTime = AssemblyTimestamp(fi => fi.LastWriteTimeUtc),
Size = 0,
})
.ToDictionary(
@@ -86,9 +94,9 @@ namespace VirtualFS.EmbeddedResource
IsReadOnly = IsReadOnly,
Path = p,
FileSystem = this,
- CreationTime = fi.CreationTimeUtc,
- LastAccessTime = fi.LastAccessTime,
- LastWriteTime = fi.LastWriteTime,
+ CreationTime = AssemblyTimestamp(fi => fi.CreationTimeUtc),
+ LastAccessTime = AssemblyTimestamp(fi => fi.LastAccessTimeUtc),
+ LastWriteTime = AssemblyTimestamp(fi => fi.LastWriteTimeUtc),
}));
// Ugly but it works (fix this - performance)
@@ -143,17 +151,15 @@ namespace VirtualFS.EmbeddedResource
if (!ret && path.IsDirectory && _pathToResource.Keys.Any(x => x.IsParentOf(path)))
{
- var fi = new System.IO.FileInfo(Uri.UnescapeDataString(new UriBuilder(Assembly.CodeBase).Path));
-
_pathToResource.Add(path, new Directory()
{
Data = null,
IsReadOnly = IsReadOnly,
Path = path,
FileSystem = this,
- CreationTime = fi.CreationTimeUtc,
- LastAccessTime = fi.LastAccessTime,
- LastWriteTime = fi.LastWriteTime,
+ CreationTime = AssemblyTimestamp(fi => fi.CreationTimeUtc),
+ LastAccessTime = AssemblyTimestamp(fi => fi.LastAccessTimeUtc),
+ LastWriteTime = AssemblyTimestamp(fi => fi.LastWriteTimeUtc),
});
ret = true;
@@ -182,7 +188,7 @@ namespace VirtualFS.EmbeddedResource
/// should return null if real path can't be determined.
public override string EntryRealPath(Path path)
{
- return Uri.UnescapeDataString(new UriBuilder(Assembly.CodeBase).Path);
+ return AssemblyLocation;
}
/// Get entries located under given path.
@@ -213,4 +219,4 @@ namespace VirtualFS.EmbeddedResource
return new VirtualStream(this, Assembly.GetManifestResourceStream(_pathToResource[path].Data.ToString()), path);
}
}
-}
\ No newline at end of file
+}
diff --git a/VirtualFS/Physical/FtpFileSystem.cs b/VirtualFS/Physical/FtpFileSystem.cs
index 5afcef2..a5b3af6 100644
--- a/VirtualFS/Physical/FtpFileSystem.cs
+++ b/VirtualFS/Physical/FtpFileSystem.cs
@@ -30,8 +30,8 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
-using System.Net.FtpClient;
using System.Text.RegularExpressions;
+using FluentFTP;
using VirtualFS.Base;
using VirtualFS.Implementation;
@@ -157,11 +157,11 @@ namespace VirtualFS.Physical
{
foreach (FtpListItem item in conn
.GetListing(GetFtpPath(path),
- FtpListOption.Modify | FtpListOption.Size | FtpListOption.DerefLinks | FtpListOption.AllFiles))
+ FtpListOption.Modify | FtpListOption.Size | FtpListOption.AllFiles))
{
switch (item.Type)
{
- case FtpFileSystemObjectType.File:
+ case FtpObjectType.File:
result.Add(new File()
{
IsReadOnly = IsReadOnly,
@@ -174,7 +174,7 @@ namespace VirtualFS.Physical
});
break;
- case FtpFileSystemObjectType.Directory:
+ case FtpObjectType.Directory:
result.Add(new Directory()
{
IsReadOnly = IsReadOnly,
@@ -185,41 +185,6 @@ namespace VirtualFS.Physical
LastAccessTime = item.Modified,
});
break;
-
- case FtpFileSystemObjectType.Link:
-
- if (item.LinkObject != null)
- {
- switch (item.LinkObject.Type)
- {
- case FtpFileSystemObjectType.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 FtpFileSystemObjectType.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;
}
}
}
@@ -366,13 +331,13 @@ namespace VirtualFS.Physical
private FtpClient GetConnection()
{
FtpClient conn = new FtpClient();
- conn.DataConnectionType = ConnectionType;
conn.Host = _ftpServer;
conn.Port = _ftpServerPort;
-
conn.Credentials = new NetworkCredential(_userName, _password);
+ conn.Config.DataConnectionType = ConnectionType;
+ conn.Connect();
return conn;
}
}
-}
\ No newline at end of file
+}
diff --git a/VirtualFS/Physical/SimpleFtpFileSystem.cs b/VirtualFS/Physical/SimpleFtpFileSystem.cs
index a2f52d2..8124df5 100644
--- a/VirtualFS/Physical/SimpleFtpFileSystem.cs
+++ b/VirtualFS/Physical/SimpleFtpFileSystem.cs
@@ -36,6 +36,7 @@ using VirtualFS.Implementation;
namespace VirtualFS.Physical
{
+#pragma warning disable SYSLIB0014
/// Ftp file system implementation.
/// This is very, very simple implementation
/// of a FTP file system. Use this when regular FTP won't do the job.
@@ -373,4 +374,5 @@ namespace VirtualFS.Physical
}
}
}
-}
\ No newline at end of file
+#pragma warning restore SYSLIB0014
+}
diff --git a/VirtualFS/VirtualFS.csproj b/VirtualFS/VirtualFS.csproj
index 00b5c1c..04bcb18 100644
--- a/VirtualFS/VirtualFS.csproj
+++ b/VirtualFS/VirtualFS.csproj
@@ -18,9 +18,9 @@
+
-