Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:ExFat.IO.ClusterStream" /> class.
        /// </summary>
        /// <param name="clusterReader">The cluster information reader.</param>
        /// <param name="clusterWriter">The cluster writer.</param>
        /// <param name="dataDescriptor">The data descriptor.</param>
        /// <param name="onDisposed">Method invoked when stream is disposed.</param>
        /// <exception cref="T:System.ArgumentException">If contiguous is true, the length must be specified</exception>
        /// <inheritdoc />
        public ClusterStream(IClusterReader clusterReader, IClusterWriter clusterWriter, DataDescriptor dataDescriptor, Action <DataDescriptor> onDisposed)
        {
            _clusterReader   = clusterReader;
            _clusterWriter   = clusterWriter;
            _startCluster    = dataDescriptor.FirstCluster;
            _contiguous      = dataDescriptor.Contiguous;
            _onDisposed      = onDisposed;
            _dataLength      = (long)dataDescriptor.PhysicalLength;
            _validDataLength = (long)dataDescriptor.LogicalLength;

            _position       = 0;
            _currentCluster = _startCluster;
        }
Beispiel #2
0
        public void LoadFromFile(String filename,
                                 Encoding encoding     = null,
                                 IClusterReader reader = null)
        {
            if (encoding == null)
            {
                encoding = Encoding.ASCII;
            }
            StreamReader sr      = new StreamReader(filename, encoding);
            String       content = sr.ReadToEnd();

            reader = reader == null ? Readers[Path.GetExtension(filename).ToLower()] : reader;
            reader.Read(content, this);
            sr.Close(); sr.Dispose();
        }