internal IFile CreateFile(S4ZipEntry entry)
        {
            if (Files.Any(x => x.Name.Equals(entry.Name, StringComparison.OrdinalIgnoreCase)))
            {
                throw new ArgumentException("File already exists", nameof(entry));
            }

            var file = new NetsphereFile(entry, this);

            _files.Add(file);
            return(file);
        }
        public IFile CreateFile(string name, byte[] data)
        {
            if (Files.Any(x => x.Name.Equals(name, StringComparison.OrdinalIgnoreCase)))
            {
                throw new ArgumentException("File already exists", nameof(name));
            }

            var entry = Zip.CreateEntry(name, data);
            var file  = new NetsphereFile(entry, this);

            _files.Add(file);
            return(file);
        }
        private void Add(S4ZipEntry entry)
        {
            NetsphereFolder parent     = null;
            var             startIndex = 0;

            while (true)
            {
                if (startIndex >= entry.FullName.Length)
                {
                    return;
                }

                var index  = entry.FullName.IndexOf("/", startIndex, StringComparison.InvariantCulture);
                var isFile = index == -1;
                if (isFile)
                {
                    index = entry.FullName.Length;
                }

                var name = entry.FullName.Substring(startIndex, index - startIndex);
                if (isFile)
                {
                    var file = new NetsphereFile(entry, parent);
                    if (parent == null)
                    {
                        _files.Add(file);
                    }
                    else
                    {
                        parent.CreateFile(entry);
                    }
                    return;
                }

                IEnumerable <IFolder> folders = parent != null ? parent.Folders : Folders;
                var folder = folders.FirstOrDefault(x => x.Name == name) ??
                             (parent == null ? CreateFolder(name) : parent.CreateFolder(name));
                parent     = (NetsphereFolder)folder;
                startIndex = index + 1;
            }
        }