示例#1
0
        private static ArchiveFolderInfo EnsureFolder(ArchiveFolderInfo parent, string[] segments)
        {
            ArchiveFolderInfo folder;

            if (segments.Length == 1)
            {
                if (segments[0].Length == 0)
                {
                    folder = parent;
                }
                else
                {
                    folder = parent.Folders.FirstOrDefault(f => string.Compare(f.Name, segments[0], StringComparison.OrdinalIgnoreCase) == 0);
                    if (folder == null)
                    {
                        folder = new ArchiveFolderInfo(parent, segments[0]);
                        parent.AddFolder(folder);
                    }
                }
            }
            else // > 1
            {
                var child       = EnsureFolder(parent, segments.Take(segments.Length - 1).ToArray());
                var lastSegment = segments[segments.Length - 1];
                folder = child.Folders.FirstOrDefault(f => string.Compare(f.Name, lastSegment, StringComparison.OrdinalIgnoreCase) == 0);
                if (folder == null)
                {
                    folder = new ArchiveFolderInfo(child, lastSegment);
                    child.AddFolder(folder);
                }
            }
            return(folder);
        }
示例#2
0
 public ArchiveFolderShellFolder(ShellFolder parent, ArchiveFolderInfo folder)
     : base(parent, new StringKeyShellItemId(folder.Name))
 {
     CanCopy = true;
     Folder  = folder;
     AddColumn(Props.System.FileAttributes, SHCOLSTATE.SHCOLSTATE_DEFAULT);
     AddColumn(Props.System.Comment, SHCOLSTATE.SHCOLSTATE_DEFAULT);
     AddColumn(Props.System.ZipFolder.Encrypted, SHCOLSTATE.SHCOLSTATE_DEFAULT);
     AddColumn(Props.System.ZipFolder.CRC32, SHCOLSTATE.SHCOLSTATE_DEFAULT);
 }
示例#3
0
        public ArchiveFolderInfo(ArchiveFolderInfo parent, string name)
        {
            if (parent == null && parent is ArchiveRootFolderInfo)
            {
                throw new ArgumentNullException(nameof(parent));
            }

            if (name == null && parent is ArchiveRootFolderInfo)
            {
                throw new ArgumentNullException(nameof(name));
            }

            Parent  = parent;
            Name    = name;
            Folders = Array.Empty <ArchiveFolderInfo>();
            Files   = Array.Empty <ArchiveFileInfo>();
        }
示例#4
0
        public void AddFolder(ArchiveFolderInfo folder)
        {
            if (folder == null)
            {
                throw new ArgumentNullException(nameof(folder));
            }

            var array = Folders != null ? new ArchiveFolderInfo[Folders.Length + 1] : new ArchiveFolderInfo[1];

            if (Folders != null)
            {
                Array.Copy(Folders, array, Folders.Length);
            }

            array[array.Length - 1] = folder;
            Folders = array;
        }