예제 #1
0
 private void ReadFileset()
 {
     using (var s = m_compression.OpenRead(FILESET_FILENAME))
     {
         if (s == null)
         {
             IsFullBackup = new FilesetData().IsFullBackup; // use default value
         }
         else
         {
             using (var fs = new StreamReader(s, ENCODING))
             {
                 FilesetData fileset = JsonConvert.DeserializeObject <FilesetData>(fs.ReadToEnd());
                 IsFullBackup = fileset.IsFullBackup;
             }
         }
     }
 }
예제 #2
0
                public void Reset()
                {
                    this.Dispose();
                    m_stream = new StreamReader(m_compression.OpenRead(FILELIST));
                    m_reader = new JsonTextReader(m_stream);

                    SkipJsonToken(m_reader, JsonToken.StartArray);

                    m_current = null;
                    m_done    = false;
                    m_first   = true;
                }
예제 #3
0
        public static IEnumerable<string> ReadBlocklist(ICompression compression, string filename, long hashsize)
        {
            var buffer = new byte[hashsize];
            using(var fs = compression.OpenRead(filename))
            {
                int s;
                while ((s = Library.Utility.Utility.ForceStreamRead(fs, buffer, buffer.Length)) != 0)
                {                    
                    if (s != buffer.Length)
                        throw new InvalidDataException("Premature End-of-stream encountered while reading blocklist hashes");

                    yield return Convert.ToBase64String(buffer);
                }

            }
        }
예제 #4
0
     public VolumeReaderBase(ICompression compression, Options options)
         : base(options)
     {
         m_compression = compression;
         if (!options.DontReadManifests)
         {
             using (var s = m_compression.OpenRead(MANIFEST_FILENAME))
             {
                 if (s == null)
                     throw new InvalidManifestException("No manifest file found in volume");
 
                 using (var fs = new StreamReader(s, ENCODING))
                     ManifestData.VerifyManifest(fs.ReadToEnd(), m_blocksize, options.BlockHashAlgorithm, options.FileHashAlgorithm);
             }
         }
     }
예제 #5
0
        private void ReadManifests(Options options)
        {
            if (!options.DontReadManifests)
            {
                using (var s = m_compression.OpenRead(MANIFEST_FILENAME))
                {
                    if (s == null)
                    {
                        throw new InvalidManifestException("No manifest file found in volume");
                    }

                    using (var fs = new StreamReader(s, ENCODING))
                        ManifestData.VerifyManifest(fs.ReadToEnd(), m_blocksize, options.BlockHashAlgorithm, options.FileHashAlgorithm);
                }
            }
        }
예제 #6
0
                        public void Reset()
                        {
                            this.Dispose();
                            m_stream = new StreamReader(m_compression.OpenRead(m_filename));
                            m_reader = new JsonTextReader(m_stream);
                            SkipJsonToken(m_reader, JsonToken.StartObject);
                            var p = SkipJsonToken(m_reader, JsonToken.PropertyName);

                            if (p == null || p.ToString() != "blocks")
                            {
                                throw new InvalidDataException(string.Format("Invalid JSON, expected property \"blocks\", but got {0}, {1}", m_reader.TokenType, m_reader.Value));
                            }
                            SkipJsonToken(m_reader, JsonToken.StartArray);

                            m_current = null;
                            m_done    = false;
                        }
예제 #7
0
        public static IEnumerable <string> ReadBlocklist(ICompression compression, string filename, long hashsize)
        {
            var buffer = new byte[hashsize];

            using (var fs = compression.OpenRead(filename))
            {
                int s;
                while ((s = Library.Utility.Utility.ForceStreamRead(fs, buffer, buffer.Length)) != 0)
                {
                    if (s != buffer.Length)
                    {
                        throw new InvalidDataException("Premature End-of-stream encountered while reading blocklist hashes");
                    }

                    yield return(Convert.ToBase64String(buffer));
                }
            }
        }
예제 #8
0
                public bool MoveNext()
                {
                    if (m_index + 1 >= m_files.Length)
                    {
                        return(false);
                    }
                    m_index++;

                    if (m_current != null)
                    {
                        try { m_current.Value.Value.Dispose(); }
                        finally { m_current = null; }
                    }

                    m_current = new KeyValuePair <string, Stream>(m_files[m_index].Substring(CONTROL_FILES_FOLDER.Length), m_compression.OpenRead(m_files[m_index]));
                    return(true);
                }
예제 #9
0
 public void Reset()
 {
     this.Dispose();
     m_current = null;
     m_stream  = m_compression.OpenRead(m_filename);
 }