Esempio n. 1
0
 public SAFArchive(Stream baseSteam, SAFMode mode, string basePath, bool calculateChecksums = true)
     : base(baseSteam, mode, SAF_ARCHIVE_HEADER_STRING)
 {
     this.basePath           = Path.GetFullPath(basePath).Trim(Path.DirectorySeparatorChar);
     this.basePathLength     = this.basePath.Length;
     this.calculateChecksums = calculateChecksums;
 }
Esempio n. 2
0
        public SAFBase(Stream baseStream, SAFMode mode, string ArchiveHeader = "SAF")
        {
            this.mode       = mode;
            this.baseStream = baseStream;

            if (mode == SAFMode.Write)
            {
                // the header identifies this as a SAF archive (and potentially the format revision).
                if (string.IsNullOrWhiteSpace(ArchiveHeader))
                {
                    throw new ArgumentException("SAF file header string cannot be null.");
                }

                this.SAFArchiveHeader = ArchiveHeader;
                streamWriter          = new StreamWriter(baseStream);

                // write the file header
                streamWriter.WriteLine(ArchiveHeader);
            }
            else
            {
                // read the file header
                this.SAFArchiveHeader = ReadNextLineUnbuffered();
            }
        }