Exemple #1
0
        ProjectedItemInfo populateDatasets(string basePath, DatasetDirectory dsd)
        {
            var rootDir = dsd.GetHeadZfs().Root;
            var info    = new ProjectedItemInfo()
            {
                ZfsItem       = rootDir,
                ProjectedForm = new FileBasicInfo()
                {
                    IsDirectory = true,
                    Name        = dsd.Name,
                },
                FullName = basePath,
            };

            mCache.Add(info.FullName, info);

            var childItems = getChildren(info.FullName, rootDir);

            var childDatasets = dsd.GetChildren();

            foreach (var childDs in childDatasets)
            {
                if (childDs.Value.Type != DataSetType.ZFS)
                {
                    continue;
                }
                childItems.Add(populateDatasets(basePath == "" ? childDs.Key : basePath + "\\" + childDs.Key, childDs.Value));
            }
            info.Children = childItems.ToArray();

            return(info);
        }
Exemple #2
0
        List <ProjectedItemInfo> getChildren(string baseName, Zpl.ZfsDirectory dir)
        {
            var projectedChildren = new List <ProjectedItemInfo>();

            foreach (var c in dir.GetChildren())
            {
                var type = c.Type;
                if (type != ZfsItemType.S_IFREG && type != ZfsItemType.S_IFDIR)
                {
                    continue;
                }

                var childInfo = new ProjectedItemInfo();
                childInfo.FullName      = baseName == "" ? c.Name : baseName + "\\" + c.Name;
                childInfo.ProjectedForm = new FileBasicInfo()
                {
                    Name           = c.Name,
                    IsDirectory    = type == ZfsItemType.S_IFDIR,
                    FileSize       = type == ZfsItemType.S_IFREG ? ((Zpl.ZfsFile)c).Length : 0,
                    Attributes     = FileAttributes.ReadOnly,
                    ChangeTime     = c.MTIME,
                    CreationTime   = c.CTIME,
                    LastAccessTime = c.ATIME,
                    LastWriteTime  = c.MTIME,
                };
                childInfo.ZfsItem = c;
                projectedChildren.Add(childInfo);
                lock (mCache)
                {
                    mCache[childInfo.FullName] = childInfo;
                }
            }
            return(projectedChildren);
        }