RemoteFileInfo.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 char FileType { get; internal set; }
  13. public long Length { get; internal set; }
  14. public int Length32 { get { return GetLength32(); } set { SetLength32(value); } }
  15. public DateTime LastWriteTime { get; internal set; }
  16. public FilePermissions FilePermissions { get; internal set; }
  17. public string Owner { get; internal set; }
  18. public string Group { get; internal set; }
  19. public bool IsDirectory { get { return (Char.ToUpper(FileType, CultureInfo.InvariantCulture) == 'D'); } }
  20. internal RemoteFileInfo()
  21. {
  22. }
  23. public override string ToString()
  24. {
  25. return Name;
  26. }
  27. private int GetLength32()
  28. {
  29. if ((Length < int.MinValue) || (Length > int.MaxValue))
  30. {
  31. throw new OverflowException(string.Format(CultureInfo.CurrentCulture, "Size {0} cannot be represented using 32-bit value", Length));
  32. }
  33. return (int) Length;
  34. }
  35. private void SetLength32(int value)
  36. {
  37. Length = value;
  38. }
  39. }
  40. }