1
0

RemoteFileInfo.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. using System.Globalization;
  3. using System.Runtime.InteropServices;
  4. namespace WinSCP
  5. {
  6. [Guid("17FF9C92-B8B6-4506-A7BA-8482D9B0AB07")]
  7. [ClassInterface(Constants.ClassInterface)]
  8. [ComVisible(true)]
  9. public sealed class RemoteFileInfo
  10. {
  11. public string Name { get; internal set; }
  12. public string FullName { get; internal set; }
  13. public char FileType { get; internal set; }
  14. public long Length { get; internal set; }
  15. public int Length32 { get { return GetLength32(); } set { SetLength32(value); } }
  16. public DateTime LastWriteTime { get; internal set; }
  17. public FilePermissions FilePermissions { get; internal set; }
  18. public string Owner { get; internal set; }
  19. public string Group { get; internal set; }
  20. public bool IsDirectory { get { return IsDirectoryFileType(FileType); } }
  21. public bool IsThisDirectory { get { return IsDirectory && (Name == "."); } }
  22. public bool IsParentDirectory { get { return IsDirectory && (Name == ".."); } }
  23. internal RemoteFileInfo()
  24. {
  25. }
  26. public override string ToString()
  27. {
  28. return Name;
  29. }
  30. private int GetLength32()
  31. {
  32. return Tools.LengthTo32Bit(Length);
  33. }
  34. private void SetLength32(int value)
  35. {
  36. Length = value;
  37. }
  38. internal static bool IsDirectoryFileType(char fileType)
  39. {
  40. return (char.ToUpper(fileType, CultureInfo.InvariantCulture) == 'D');
  41. }
  42. }
  43. }