Seek() публичный Метод

public Seek ( long offset, SeekOrigin origin ) : void
offset long
origin SeekOrigin
Результат void
Пример #1
0
        private static void Seek(RubyIO /*!*/ self, long pos, int seekOrigin)
        {
            if (seekOrigin < 0 || seekOrigin > 2)
            {
                throw RubyExceptions.CreateArgumentError("Invalid argument");
            }

            if (self.IsConsoleDescriptor())
            {
                throw new Errno.BadFileDescriptorError();
            }

            // TODO: make sure we assert stream is not actually closed
            if (self.Closed)
            {
                throw RubyExceptions.CreateArgumentError("trying to seek on a non-existent stream?");
            }

            SeekOrigin origin = SeekOrigin.Current;

            if (seekOrigin == SEEK_SET)
            {
                origin = SeekOrigin.Begin;
            }
            else if (seekOrigin == SEEK_END)
            {
                origin = SeekOrigin.End;
            }

            self.Seek(pos, origin);
        }
Пример #2
0
        public static void Pos(RubyIO /*!*/ self, [DefaultProtocol] int value)
        {
            if (self.IsConsoleDescriptor())
            {
                throw new Errno.BadFileDescriptorError();
            }

            self.Seek(value, SeekOrigin.Begin);
        }
Пример #3
0
        public static MutableString /*!*/ Read(RubyClass /*!*/ self,
                                               [DefaultProtocol, NotNull] MutableString /*!*/ path, [DefaultProtocol] int length, [DefaultProtocol, Optional] int offset)
        {
            if (offset < 0)
            {
                throw new Errno.InvalidError();
            }

            if (length < 0)
            {
                throw RubyExceptions.CreateArgumentError(String.Format("negative length {0} given", length));
            }

            using (RubyIO io = OpenFileForRead(self.Context, path)) {
                if (offset > 0)
                {
                    io.Seek(offset, SeekOrigin.Begin);
                }
                return(Read(io, length, null));
            }
        }
Пример #4
0
 public static void Pos(RubyIO/*!*/ self, [DefaultProtocol]IntegerValue pos) {
     self.Seek(pos.ToInt64(), SeekOrigin.Begin);
 }
Пример #5
0
 public static object SysSeek(RubyIO/*!*/ self, [DefaultProtocol]IntegerValue pos, [DefaultProtocol, DefaultParameterValue(SEEK_SET)]int seekOrigin) {
     self.Flush();
     self.Seek(pos.ToInt64(), RubyIO.ToSeekOrigin(seekOrigin));
     return pos.ToObject();
 }
Пример #6
0
 public static int Seek(RubyIO/*!*/ self, [DefaultProtocol]IntegerValue pos, [DefaultProtocol, DefaultParameterValue(SEEK_SET)]int seekOrigin) {
     self.Seek(pos.ToInt64(), RubyIO.ToSeekOrigin(seekOrigin));
     return 0;
 }
Пример #7
0
 public static void Rewind(RubyContext/*!*/ context, RubyIO/*!*/ self) {
     self.Seek(0, SeekOrigin.Begin);
     self.LineNumber = 0;
 }
Пример #8
0
        public static void Pos(RubyIO/*!*/ self, [DefaultProtocol]int value) {
            if (self.IsConsoleDescriptor()) {
                throw new Errno.BadFileDescriptorError();
            }

            self.Seek(value, SeekOrigin.Begin);
        }
Пример #9
0
        private static void Seek(RubyIO/*!*/ self, long pos, int seekOrigin) {
            if (seekOrigin < 0 || seekOrigin > 2) {
                throw RubyExceptions.CreateArgumentError("Invalid argument");
            }

            if (self.IsConsoleDescriptor()) {
                throw new Errno.BadFileDescriptorError();
            }

            // TODO: make sure we assert stream is not actually closed
            if (self.Closed) {
                throw RubyExceptions.CreateArgumentError("trying to seek on a non-existent stream?");
            }

            SeekOrigin origin = SeekOrigin.Current;
            if (seekOrigin == SEEK_SET) {
                origin = SeekOrigin.Begin;
            } else if (seekOrigin == SEEK_END) {
                origin = SeekOrigin.End;
            }

            self.Seek(pos, origin);
        }
Пример #10
0
 public static void Pos(RubyIO /*!*/ self, [DefaultProtocol] IntegerValue pos)
 {
     self.Seek(pos.ToInt64(), SeekOrigin.Begin);
 }
Пример #11
0
 public static object SysSeek(RubyIO /*!*/ self, [DefaultProtocol] IntegerValue pos, [DefaultProtocol, DefaultParameterValue(SEEK_SET)] int seekOrigin)
 {
     self.Flush();
     self.Seek(pos.ToInt64(), RubyIO.ToSeekOrigin(seekOrigin));
     return(pos.ToObject());
 }
Пример #12
0
 public static int Seek(RubyIO /*!*/ self, [DefaultProtocol] IntegerValue pos, [DefaultProtocol, DefaultParameterValue(SEEK_SET)] int seekOrigin)
 {
     self.Seek(pos.ToInt64(), RubyIO.ToSeekOrigin(seekOrigin));
     return(0);
 }
Пример #13
0
 public static void Rewind(RubyContext /*!*/ context, RubyIO /*!*/ self)
 {
     self.Seek(0, SeekOrigin.Begin);
     self.LineNumber = 0;
 }