Inheritance: RubyObject
示例#1
0
文件: Dir.cs 项目: ltwlf/IronSP
        public static MutableString Read(RubyContext /*!*/ context, RubyDir /*!*/ self)
        {
            self.ThrowIfClosed();

            if (self._pos + 1 > self._rawEntries.Length)
            {
                return(null);
            }

            MutableString ret;

            if (self._pos == -2)
            {
                ret = context.EncodePath(".");
            }
            else if (self._pos == -1)
            {
                ret = context.EncodePath("..");
            }
            else
            {
                ret = context.EncodePath(context.Platform.GetFileName(self._rawEntries[self._pos]));
            }
            self._pos++;
            return(ret);
        }
示例#2
0
        public static RubyDir /*!*/ Each(BlockParam block, RubyDir /*!*/ self)
        {
            self.ThrowIfClosed();

            RubyDir.ForEach(block, self, self._dirName);
            return(self);
        }
示例#3
0
文件: Dir.cs 项目: ltwlf/IronSP
        public static RubyDir /*!*/ Rewind(RubyDir /*!*/ self)
        {
            self.ThrowIfClosed();

            self._pos = -2;
            return(self);
        }
示例#4
0
        public static MutableString /*!*/ Read(RubyDir /*!*/ self)
        {
            self.ThrowIfClosed();

            if (self._pos + 1 > self._rawEntries.Length)
            {
                return(null);
            }

            MutableString ret;

            if (self._pos == -2)
            {
                ret = MutableString.Create(".");
            }
            else if (self._pos == -1)
            {
                ret = MutableString.Create("..");
            }
            else
            {
                ret = MutableString.Create(Path.GetFileName(self._rawEntries[self._pos]));
            }
            self._pos++;
            return(ret);
        }
示例#5
0
文件: Dir.cs 项目: ltwlf/IronSP
        public static int SetPosition(RubyDir /*!*/ self, int pos)
        {
            self.ThrowIfClosed();

            self._pos = pos - 2;
            return(pos);
        }
示例#6
0
        public static object Open(ConversionStorage <MutableString> /*!*/ toPath, BlockParam block, RubyClass /*!*/ self, object dirname)
        {
            RubyDir rd = new RubyDir(self, Protocols.CastToPath(toPath, dirname));

            try {
                object result;
                block.Yield(rd, out result);
                return(result);
            } finally {
                Close(rd);
            }
        }
示例#7
0
文件: Dir.cs 项目: ltwlf/IronSP
        public static object Open(BlockParam block, RubyClass /*!*/ self, [NotNull] MutableString /*!*/ dirname)
        {
            RubyDir rd = new RubyDir(self, dirname);

            try {
                object result;
                block.Yield(rd, out result);
                return(result);
            } finally {
                Close(rd);
            }
        }
示例#8
0
文件: Dir.cs 项目: atczyc/ironruby
        public static RubyDir/*!*/ Reinitialize(RubyDir/*!*/ self, [NotNull]MutableString/*!*/ dirname) {
            self.Close();

            string strName = self.ImmediateClass.Context.DecodePath(dirname);
            try {
                self._rawEntries = self.Platform.GetFileSystemEntries(strName, "*");
            } catch (Exception ex) {
                throw ToRubyException(ex, strName, DirectoryOperation.Open);
            }
            self._dirName = dirname.Clone();
            self._pos = -2;
            return self;
        }
示例#9
0
文件: Dir.cs 项目: ltwlf/IronSP
        public static MutableString GetPath(RubyContext /*!*/ context, RubyDir /*!*/ self)
        {
            if (context.RubyOptions.Compatibility < RubyCompatibility.Ruby19)
            {
                self.ThrowIfClosed();
            }
            else if (self.Closed)
            {
                return(null);
            }

            return(self._dirName.Clone());
        }
示例#10
0
文件: Dir.cs 项目: ltwlf/IronSP
        public static RubyDir /*!*/ Reinitialize(RubyDir /*!*/ self, [NotNull] MutableString /*!*/ dirname)
        {
            self.Close();

            string strName = self.ImmediateClass.Context.DecodePath(dirname);

            try {
                self._rawEntries = self.Platform.GetFileSystemEntries(strName, "*");
            } catch (Exception ex) {
                throw ToRubyException(ex, strName, DirectoryOperation.Open);
            }
            self._dirName = dirname.Clone();
            self._pos     = -2;
            return(self);
        }
示例#11
0
文件: Dir.cs 项目: ltwlf/IronSP
        public static RubyDir /*!*/ Seek(RubyDir /*!*/ self, int pos)
        {
            self.ThrowIfClosed();

            if (pos < 0)
            {
                self._pos = -2;
            }
            else if (pos > self._rawEntries.Length + 2)
            {
                self._pos = self._rawEntries.Length;
            }
            else
            {
                self._pos = pos - 2;
            }
            return(self);
        }
示例#12
0
文件: Dir.cs 项目: atczyc/ironruby
        public static int GetCurrentPosition(RubyDir/*!*/ self) {
            self.ThrowIfClosed();

            return self._pos + 2;
        }
示例#13
0
文件: Dir.cs 项目: atczyc/ironruby
        public static int SetPosition(RubyDir/*!*/ self, int pos) {
            self.ThrowIfClosed();

            self._pos = pos - 2;
            return pos;
        }
示例#14
0
文件: Dir.cs 项目: atczyc/ironruby
 public static object Each(RubyContext/*!*/ context, BlockParam block, RubyDir/*!*/ self) {
     return self.EnumerateEntries(context, block, self);
 }
示例#15
0
文件: Dir.cs 项目: atczyc/ironruby
        public static MutableString GetPath(RubyContext/*!*/ context, RubyDir/*!*/ self) {
            if (context.RubyOptions.Compatibility == RubyCompatibility.Ruby18) {
                self.ThrowIfClosed();
            } else if (self.Closed) {
                return null;
            }

            return self._dirName.Clone();
        }
示例#16
0
文件: Dir.cs 项目: atczyc/ironruby
        public static object Open(BlockParam block, RubyClass/*!*/ self, [NotNull]MutableString/*!*/ dirname) {
            RubyDir rd = new RubyDir(self, dirname);

            try {
                object result;
                block.Yield(rd, out result);
                return result;
            } finally {
                Close(rd);
            }
        }
示例#17
0
文件: Dir.cs 项目: atczyc/ironruby
 public static void Close(RubyDir/*!*/ self) {
     self.ThrowIfClosed();
     self.Close();
 }
示例#18
0
文件: Dir.cs 项目: atczyc/ironruby
        public static RubyDir/*!*/ Seek(RubyDir/*!*/ self, int pos) {
            self.ThrowIfClosed();

            if (pos < 0) {
                self._pos = -2;
            } else if (pos > self._rawEntries.Length + 2) {
                self._pos = self._rawEntries.Length;
            } else {
                self._pos = pos - 2;
            }
            return self;
        }
示例#19
0
文件: Dir.cs 项目: ltwlf/IronSP
 public static object Each(RubyContext /*!*/ context, BlockParam block, RubyDir /*!*/ self)
 {
     return(self.EnumerateEntries(context, block, self));
 }
示例#20
0
文件: Dir.cs 项目: jxnmaomao/ironruby
        public static MutableString/*!*/ GetPath(RubyDir/*!*/ self) {
            self.ThrowIfClosed();

            return self._dirName;
        }
示例#21
0
文件: Dir.cs 项目: jxnmaomao/ironruby
        public static RubyDir/*!*/ Each(BlockParam block, RubyDir/*!*/ self) {
            self.ThrowIfClosed();

            RubyDir.ForEach(block, self, self._dirName);
            return self;
        }
示例#22
0
文件: Dir.cs 项目: jxnmaomao/ironruby
        public static void Close(RubyDir/*!*/ self) {
            self.ThrowIfClosed();

            self._closed = true;
        }
示例#23
0
文件: Dir.cs 项目: ltwlf/IronSP
        public static int GetCurrentPosition(RubyDir /*!*/ self)
        {
            self.ThrowIfClosed();

            return(self._pos + 2);
        }
示例#24
0
文件: Dir.cs 项目: jxnmaomao/ironruby
        public static MutableString/*!*/ Read(RubyDir/*!*/ self) {
            self.ThrowIfClosed();

            if (self._pos + 1 > self._rawEntries.Length) {
                return null;
            }

            MutableString ret;
            if (self._pos == -2) {
                ret = MutableString.CreateAscii(".");
            } else if (self._pos == -1) {
                ret = MutableString.CreateAscii("..");
            } else {
                ret = MutableString.Create(Path.GetFileName(self._rawEntries[self._pos]), RubyEncoding.Path);
            }
            self._pos++;
            return ret;
        }
示例#25
0
文件: Dir.cs 项目: atczyc/ironruby
        public static MutableString Read(RubyContext/*!*/ context, RubyDir/*!*/ self) {
            self.ThrowIfClosed();

            if (self._pos + 1 > self._rawEntries.Length) {
                return null;
            }

            MutableString ret;
            if (self._pos == -2) {
                ret = context.EncodePath(".");
            } else if (self._pos == -1) {
                ret = context.EncodePath("..");
            } else {
                ret = context.EncodePath(context.Platform.GetFileName(self._rawEntries[self._pos]));
            }
            self._pos++;
            return ret;
        }
示例#26
0
        public static void Close(RubyDir /*!*/ self)
        {
            self.ThrowIfClosed();

            self._closed = true;
        }
示例#27
0
文件: Dir.cs 项目: atczyc/ironruby
        public static RubyDir/*!*/ Rewind(RubyDir/*!*/ self) {
            self.ThrowIfClosed();

            self._pos = -2;
            return self;
        }
示例#28
0
文件: Dir.cs 项目: ltwlf/IronSP
 public static void Close(RubyDir /*!*/ self)
 {
     self.ThrowIfClosed();
     self.Close();
 }
示例#29
0
文件: Dir.cs 项目: nieve/ironruby
        public static object Open(ConversionStorage<MutableString>/*!*/ toPath, BlockParam block, RubyClass/*!*/ self, object dirname) {
            RubyDir rd = new RubyDir(self, Protocols.CastToPath(toPath, dirname));

            try {
                object result;
                block.Yield(rd, out result);
                return result;
            } finally {
                Close(rd);
            }
        }
示例#30
0
        public static MutableString /*!*/ GetPath(RubyDir /*!*/ self)
        {
            self.ThrowIfClosed();

            return(self._dirName);
        }