Exemple #1
0
 public static object Load(RubyScope/*!*/ scope, RubyModule/*!*/ self, object source, [Optional]Proc proc) {
     Stream stream = null;
     if (source != null) {
         stream = new IOWrapper(self.Context, source, FileAccess.Read);
     }
     if (stream == null || !stream.CanRead) {
         throw RubyExceptions.CreateTypeError("instance of IO needed");
     }
     BinaryReader reader = new BinaryReader(stream);
     MarshalReader loader = new MarshalReader(reader, scope.RubyContext, scope.GlobalScope, proc);
     return loader.Load();
 }
Exemple #2
0
            internal GZipFile(RubyClass/*!*/ cls, object io, CompressionMode mode)
                : base(cls)
            {
                var underlyingStream = new IOWrapper(
                    cls.Context,
                    io,
                    canRead: mode == CompressionMode.Decompress,
                    canWrite: mode == CompressionMode.Compress,
                    canSeek: false,
                    canFlush: true,
                    canClose: true,
                    bufferSize: BufferSize);

                _stream = new GZipStream(underlyingStream, mode, leaveOpen: true);
            }
Exemple #3
0
        public static object Dump(RubyModule/*!*/ self, object obj, object io, [Optional]int? limit) {
            Stream stream = null;
            if (io != null) {
                stream = new IOWrapper(self.Context, io, FileAccess.Write);
            }
            if (stream == null || !stream.CanWrite) {
                throw RubyExceptions.CreateTypeError("instance of IO needed");
            }

            BinaryWriter writer = new BinaryWriter(stream);
            MarshalWriter dumper = new MarshalWriter(writer, self.Context, limit);
            dumper.Dump(obj);
            return io;
        }