aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Integration/Storage/StorageItem.cs
blob: 6894f7111e5a02930ee6c452446fc25b27a4d991 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Core;
using Tango.PMR.IO;

namespace Tango.Integration.Storage
{
    public abstract class StorageItem : ExtendedObject
    {
        private String _path;
        public String Path
        {
            get { return _path; }
            set { _path = value; RaisePropertyChangedAuto(); }
        }

        public String Name
        {
            get { return System.IO.Path.GetFileName(Path); }
        }

        public String Parent
        {
            get
            {
                if (Path == "/" || Path == null) return null;

                String root = System.IO.Path.GetPathRoot(Path);
                var parent = Directory.GetParent(Path);

                if (root == "\\")
                {
                    return parent.FullName.Replace(parent.Root.FullName, "/").Replace("\\", "/");
                }
                else if (parent != null)
                {
                    return parent.FullName;
                }
                else
                {
                    return null;
                }
            }
        }

        public DateTime LastModified { get; set; }

        public FileAttribute Attribute { get; set; }
    }
}