Example #1
0
        private int ReadDirectory(DirectoryInfo rootDirectoryInfo, DirectoryInfo directoryInfo, List <HdrFile> hdrFiles)
        {
            int count = 0;

            foreach (FileInfo fileInfo in directoryInfo.GetFiles())
            {
                if (!IgnoreFiles.Contains(fileInfo.Name.ToLowerInvariant()))
                {
                    string directoryPath = fileInfo.DirectoryName.Replace(rootDirectoryInfo.FullName, "");
                    directoryPath = OsToHdrPath(directoryPath);
                    string  fullPath = directoryPath + fileInfo.Name;
                    HdrFile hdrFile  = new HdrFile();
                    hdrFile.Data             = ReadFile(fileInfo.FullName);
                    hdrFile.FileName         = fileInfo.Name;
                    hdrFile.FileExtension    = fileInfo.Extension;
                    hdrFile.HdrDirectoryPath = directoryPath;
                    hdrFile.HdrFullPath      = fullPath;
                    hdrFiles.Add(hdrFile);
                }
            }
            foreach (DirectoryInfo subDirectoryInfo in directoryInfo.GetDirectories())
            {
                count += ReadDirectory(rootDirectoryInfo, subDirectoryInfo, hdrFiles);
            }
            return(++count);
        }
Example #2
0
        public HdrArchive Read(string sourcePath)
        {
            byte[]         hdrFile          = ReadFile(sourcePath);
            IBuffer        buffer           = BufferProvider.Provide(hdrFile);
            HdrHeader      header           = ReadHeader(buffer);
            List <HdrFile> files            = new List <HdrFile>();
            int            folderIndexStart = header.IndexOffset;
            int            totalFiles       = 0;
            int            currentFile      = 0;

            for (int i = 0; i < header.FolderCount; i++)
            {
                buffer.Position = folderIndexStart + i * IndexBlockSize;
                HdrIndex folderIndex = ReadIndex(buffer);
                buffer.Position = folderIndex.Offset;
                for (int j = 0; j < folderIndex.Length; j++)
                {
                    HdrIndex fileIndex = ReadIndex(buffer);
                    int      offset    = fileIndex.Offset;
                    int      lenght    = fileIndex.Length;
                    string   ext;
                    if (Path.HasExtension(fileIndex.Name))
                    {
                        ext = Path.GetExtension(fileIndex.Name);
                        switch (ext)
                        {
                        case ".pts":
                            // PTS-Files are PNG files with the first 4byte beeing lengt of the data.
                            // We already know the length from the index.
                            // offset += 4;
                            // lenght -= 4;
                            break;
                        }
                    }
                    else
                    {
                        ext = "";
                    }
                    HdrFile file = new HdrFile();
                    file.FileExtension    = ext;
                    file.FileName         = fileIndex.Name;
                    file.HdrDirectoryPath = folderIndex.Name;
                    file.HdrFullPath      = folderIndex.Name + fileIndex.Name;
                    file.Data             = buffer.GetBytes(offset, lenght);
                    file.Offset           = offset;
                    file.Length           = lenght;
                    file.Extension        = ext;
                    files.Add(file);
                    currentFile++;
                }
                totalFiles += folderIndex.Length;
                OnProgressChanged(totalFiles, currentFile);
            }
            return(new HdrArchive(files, header));
        }
Example #3
0
 public void Remove(HdrFile file)
 {
     Files.Add(file);
 }
Example #4
0
 public void Add(HdrFile file)
 {
     Files.Remove(file);
 }