private void OpenStream(IStreamWrapper streamObj, string encoding = null, string lineDelimiter = "\n", string eolDelimiter = null)
        {
            TextReader imReader;

            if (encoding == null)
            {
                imReader = FileOpener.OpenReader(streamObj.GetUnderlyingStream());
            }
            else
            {
                var enc = КодировкаТекста.GetEncoding(encoding);
                imReader = FileOpener.OpenReader(streamObj.GetUnderlyingStream(), enc);
            }
            _reader = GetCustomLineFeedReader(imReader, lineDelimiter, eolDelimiter, AnalyzeDefaultLineFeed);
        }
Пример #2
0
        private void OpenStream(IStreamWrapper streamObj, IValue encoding = null, string lineDelimiter = "\n", string eolDelimiter = null)
        {
            TextReader imReader;

            if (encoding == null)
            {
                imReader = Environment.FileOpener.OpenReader(streamObj.GetUnderlyingStream(), Encoding.Default);
            }
            else
            {
                var enc = TextEncodingEnum.GetEncoding(encoding);
                imReader = Environment.FileOpener.OpenReader(streamObj.GetUnderlyingStream(), enc);
            }
            _reader = GetCustomLineFeedReader(imReader, lineDelimiter, eolDelimiter, AnalyzeDefaultLineFeed);
        }
Пример #3
0
 public void Open(IStreamWrapper stream, string password = null, FileNamesEncodingInZipFile encoding = FileNamesEncodingInZipFile.Auto)
 {
     ZipFile.DefaultEncoding = Encoding.GetEncoding(866);
     // f**k non-russian encodings on non-ascii files
     _zip = ZipFile.Read(stream.GetUnderlyingStream(), new ReadOptions()
     {
         Encoding = ChooseEncoding(encoding)
     });
     _zip.Password = password;
 }
Пример #4
0
        public DataWriter(IStreamWrapper streamObj, IValue textEncoding, ByteOrderEnum?byteOrder, string lineSplitter, string convertibleSplitterOfLines, bool writeBOM)
        {
            ByteOrder    = byteOrder ?? ByteOrderEnum.LittleEndian;
            LineSplitter = lineSplitter ?? "\r\n";
            ConvertibleSplitterOfLines = convertibleSplitterOfLines;
            _writeBOM    = writeBOM;
            TextEncoding = textEncoding;

            _binaryWriter = new BinaryWriter(streamObj.GetUnderlyingStream(), _workingEncoding);
        }
Пример #5
0
        public void CopyTo(IValue targetStream, int bufferSize = 0)
        {
            IStreamWrapper sw = targetStream.GetRawValue() as IStreamWrapper;
            if (sw == null)
                throw RuntimeException.InvalidArgumentType("targetStream");

            var stream = sw.GetUnderlyingStream();
            if (bufferSize == 0)
                _underlyingStream.CopyTo(stream);
            else
                _underlyingStream.CopyTo(stream, bufferSize);
        }
Пример #6
0
        public void CopyTo(object targetStream, int bufferSize = 0)
        {
            IStreamWrapper sw = targetStream as IStreamWrapper;

            if (sw == null)
            {
                throw RuntimeException.InvalidArgumentType("targetStream");
            }

            var stream = sw.GetUnderlyingStream();

            if (bufferSize == 0)
            {
                _underlyingStream.CopyTo(stream);
            }
            else
            {
                _underlyingStream.CopyTo(stream, bufferSize);
            }
        }
Пример #7
0
 public static IRuntimeContextInstance Constructor1(IStreamWrapper stream, IValue textEncoding = null, ByteOrderEnum?byteOrder = null, string lineSplitter = null, string convertibleSplitterOfLines = null)
 {
     return(new DataReader(stream.GetUnderlyingStream(), textEncoding, byteOrder, lineSplitter, convertibleSplitterOfLines));
 }