示例#1
0
文件: IoOps.cs 项目: ltwlf/IronSP
        public static int SysOpen(RubyClass /*!*/ self, [NotNull] MutableString path, [Optional] MutableString mode, [Optional] int perm)
        {
            if (RubyFileOps.DirectoryExists(self.Context, path))
            {
                // TODO: What file descriptor should be returned for a directory?
                return(-1);
            }
            RubyIO io       = new RubyFile(self.Context, path.ToString(), IOModeEnum.Parse(mode));
            int    fileDesc = io.GetFileDescriptor();

            io.Close();
            return(fileDesc);
        }
示例#2
0
        public static object ChangeDirectory(RubyContext /*!*/ context, object self)
        {
#if !SILVERLIGHT
            string defaultDirectory = RubyFileOps.GetHomeDirectory(context);
            if (defaultDirectory == null)
            {
                throw RubyExceptions.CreateArgumentError("HOME / USERPROFILE not set");
            }

            return(ChangeDirectory(self, MutableString.Create(defaultDirectory)));
#else
            throw new InvalidOperationException();
#endif
        }
示例#3
0
 public static bool IsFile(RubyModule /*!*/ self, [DefaultProtocol, NotNull] MutableString /*!*/ path)
 {
     return(RubyFileOps.FileExists(self.Context, path));
 }
示例#4
0
 public static bool Exists(RubyClass /*!*/ self, [DefaultProtocol, NotNull] MutableString /*!*/ path)
 {
     return(RubyFileOps.Exists(self, path));
 }
示例#5
0
文件: Dir.cs 项目: yyyyj/ironruby
 public static bool Exists(ConversionStorage <MutableString> /*!*/ toPath, RubyModule /*!*/ self, object path)
 {
     return(RubyFileOps.DirectoryExists(self.Context, Protocols.CastToPath(toPath, path)));
 }