RemoteFileInfo.cs 1.7 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 (Char.ToUpper(FileType, CultureInfo.InvariantCulture) == 'D'); } }
  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. if ((Length < int.MinValue) || (Length > int.MaxValue))
  33. {
  34. throw new OverflowException(string.Format(CultureInfo.CurrentCulture, "Size {0} cannot be represented using 32-bit value", Length));
  35. }
  36. return (int) Length;
  37. }
  38. private void SetLength32(int value)
  39. {
  40. Length = value;
  41. }
  42. }
  43. }