WebDavMtpStoreItem.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System;
  2. using System.Linq;
  3. using MediaDevices;
  4. using Mtp2Dav.WebDAVSharp.Server._1d2086a502937936ebc6bfe19cfa15d855be1c31.Stores;
  5. namespace Mtp2Dav.MtpStore._1d2086a502937936ebc6bfe19cfa15d855be1c31
  6. {
  7. internal abstract class WebDavMtpStoreItem : IWebDavStoreItem
  8. {
  9. //------------- const and fields ---------
  10. private static readonly DateTime InvaliDateTime = new DateTime(1900, 1, 1);
  11. //------------- inhertable implement ---------
  12. protected WebDavMtpStore Store { get; }
  13. protected MediaFileInfo FileInfo { get; }
  14. public string ItemPath { get; }
  15. public string Name { get; set; }
  16. //------------- transparent implement ----------------
  17. public virtual int Hidden => 0;
  18. public virtual DateTime CreationDate => FileInfo?.CreationTime ?? InvaliDateTime;
  19. public virtual DateTime ModificationDate => FileInfo?.LastWriteTime ?? InvaliDateTime;
  20. public abstract bool IsCollection { get; }
  21. //------------- ctor -------------------------
  22. protected WebDavMtpStoreItem(WebDavMtpStore store, string path)
  23. {
  24. Store = store;
  25. ItemPath = path;
  26. Name = ItemPath.Split(new[] { '\\' }, StringSplitOptions.RemoveEmptyEntries).LastOrDefault() ?? ItemPath;
  27. FileInfo = store.GetInfo(ItemPath);
  28. }
  29. }
  30. }