mirror of
https://github.com/winscp/winscp.git
synced 2026-10-24 02:28:55 +03:00
https://winscp.net/tracker/856 ---- @mjkent: Add interfaces to .NET assembly for improved testability This PR extracts interfaces from the main WinSCP .NET assembly classes (Session, SessionOptions, TransferOptions, etc.), enabling: Unit testing - Mock ISession to test code that uses WinSCP without requiring actual SFTP/FTP connections Dependency injection - Register interfaces in DI containers for cleaner architecture Decoupling - Program against abstractions rather than concrete implementations This change should be non-breaking, but I'm new to this project so review and feedback appreciated!
53 lines
1.6 KiB
C#
53 lines
1.6 KiB
C#
using System;
|
|
using System.Globalization;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace WinSCP
|
|
{
|
|
[Guid("17FF9C92-B8B6-4506-A7BA-8482D9B0AB07")]
|
|
[ClassInterface(Constants.ClassInterface)]
|
|
[ComVisible(true)]
|
|
public sealed class RemoteFileInfo : IRemoteFileInfo
|
|
{
|
|
public string Name { get; internal set; }
|
|
public string FullName { get; internal set; }
|
|
public char FileType { get; internal set; }
|
|
public long Length { get; internal set; }
|
|
public int Length32 { get { return GetLength32(); } set { SetLength32(value); } }
|
|
|
|
public DateTime LastWriteTime { get; internal set; }
|
|
public FilePermissions FilePermissions { get; internal set; }
|
|
|
|
public string Owner { get; internal set; }
|
|
public string Group { get; internal set; }
|
|
|
|
public bool IsDirectory { get { return IsDirectoryFileType(FileType); } }
|
|
public bool IsThisDirectory { get { return IsDirectory && (Name == "."); } }
|
|
public bool IsParentDirectory { get { return IsDirectory && (Name == ".."); } }
|
|
|
|
internal RemoteFileInfo()
|
|
{
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return Name;
|
|
}
|
|
|
|
private int GetLength32()
|
|
{
|
|
return Tools.LengthTo32Bit(Length);
|
|
}
|
|
|
|
private void SetLength32(int value)
|
|
{
|
|
Length = value;
|
|
}
|
|
|
|
internal static bool IsDirectoryFileType(char fileType)
|
|
{
|
|
return (char.ToUpper(fileType, CultureInfo.InvariantCulture) == 'D');
|
|
}
|
|
}
|
|
}
|