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); }
public static IOInfo Parse(RubyContext /*!*/ context, MutableString /*!*/ modeAndEncoding) { if (!modeAndEncoding.IsAscii()) { throw IOModeEnum.IllegalMode(modeAndEncoding.ToAsciiString()); } string[] parts = modeAndEncoding.ToString().Split(':'); return(new IOInfo( IOModeEnum.Parse(parts[0]), (parts.Length > 1) ? TryParseEncoding(context, parts[1]) : null, (parts.Length > 2) ? TryParseEncoding(context, parts[2]) : null )); }
public static RubyFile /*!*/ CreateFile(RubyClass /*!*/ self, [NotNull] MutableString /*!*/ path, MutableString mode) { return(new RubyFile(self.Context, path, IOModeEnum.Parse(mode))); }
public static RubyFile /*!*/ CreateFile(RubyClass /*!*/ self, [DefaultProtocol, NotNull] Union <int, MutableString> descriptorOrPath, [Optional, DefaultProtocol] MutableString mode, [Optional] int permission) { if (descriptorOrPath.IsFixnum()) { return(new RubyFile( self.Context, RubyIOOps.GetDescriptorStream(self.Context, descriptorOrPath.Fixnum()), descriptorOrPath.Fixnum(), IOModeEnum.Parse(mode) )); } else { // TODO: permissions return(CreateFile(self, descriptorOrPath.Second, mode)); } }
public static IOMode Parse(MutableString mode, IOMode defaultMode) { return((mode != null) ? IOModeEnum.Parse(mode.ToString()) : defaultMode); }
public static RubyIO /*!*/ Reinitialize(RubyIO /*!*/ self, [DefaultProtocol] int descriptor, [DefaultProtocol, Optional, NotNull] MutableString mode) { return(Reinitialize(self, descriptor, (int)IOModeEnum.Parse(mode))); }
public static RubyIO /*!*/ OpenPipe(RubyContext /*!*/ context, RubyClass /*!*/ self, [DefaultProtocol, NotNull] MutableString /*!*/ command, [DefaultProtocol, Optional, NotNull] MutableString modeString) { return(OpenPipe(context, command, IOModeEnum.Parse(modeString))); }
public static RubyIO /*!*/ Reopen(RubyIO /*!*/ self, [DefaultProtocol, NotNull] MutableString /*!*/ path, [DefaultProtocol, Optional, NotNull] MutableString mode) { return(Reopen(self, path, (int)IOModeEnum.Parse(mode, self.Mode))); }