Exemplo n.º 1
0
        private void ReadStream(Stream stream)
        {
            Files = new List <VirtualFileEntry>();
            bool             hasFiles       = false;
            int              topDirectories = 0;
            VirtualFileEntry topDirectory   = null;

            foreach (var entry in ReadEntries(stream))
            {
                Files.Add(entry);
                if (VirtualPath.Length == 0 && string.IsNullOrEmpty(entry.Path))
                {
                    if (entry.IsDirectory)
                    {
                        topDirectory = entry;
                        topDirectories++;
                    }
                    else
                    {
                        hasFiles = true;
                    }
                }
            }

            if (FlattenInitialDirectory && VirtualPath.Length == 0 && !hasFiles && topDirectories == 1)
            {
                this.VirtualPath = topDirectory.FullPath;
            }
        }
Exemplo n.º 2
0
		protected override IEnumerable<VirtualFileEntry> ReadEntries (Stream stream)
		{
			var foundDirs = new Dictionary<string, bool>();
			var archive = RarArchive.Open(stream);
			foreach (var entry in archive.Entries)
			{
				var file = new VirtualFileEntry(entry.FilePath, entry.IsDirectory);
				
				if (!string.IsNullOrEmpty(file.Path) && !foundDirs.ContainsKey(file.Path))
				{
					foundDirs.Add(file.Path, true);
					yield return new VirtualFileEntry(file.Path, true);
				}
				
				yield return file;
			}
		}
Exemplo n.º 3
0
        protected override IEnumerable <VirtualFileEntry> ReadEntries(Stream stream)
        {
            var foundDirs = new Dictionary <string, bool>();
            var archive   = RarArchive.Open(stream);

            foreach (var entry in archive.Entries)
            {
                var file = new VirtualFileEntry(entry.FilePath, entry.IsDirectory);

                if (!string.IsNullOrEmpty(file.Path) && !foundDirs.ContainsKey(file.Path))
                {
                    foundDirs.Add(file.Path, true);
                    yield return(new VirtualFileEntry(file.Path, true));
                }

                yield return(file);
            }
        }