本文整理汇总了C#中IOMode类的典型用法代码示例。如果您正苦于以下问题:C# IOMode类的具体用法?C# IOMode怎么用?C# IOMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IOMode类属于命名空间,在下文中一共展示了IOMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RubyIO
// TODO: hack
public RubyIO(RubyContext/*!*/ context, StreamReader reader, StreamWriter writer, string/*!*/ modeString)
: this(context) {
_mode = ParseIOMode(modeString, out _preserveEndOfLines);
_stream = new DuplexStream(reader, writer);
ResetLineNumbersForReadOnlyFiles(context);
}
示例2: Parameter
/// <summary>
/// Constructor for a parameter
/// </summary>
/// <param name="mode"></param>
/// <param name="variableType"></param>
public Parameter(string name,IOMode mode, VariableType variableType,int size)
{
this.mode = mode;
this.variableType = variableType;
this.name = name;
this.size = size;
}
示例3: OpenFileStream
public static Stream/*!*/ OpenFileStream(RubyContext/*!*/ context, string/*!*/ path, IOMode mode) {
ContractUtils.RequiresNotNull(path, "path");
FileAccess access = mode.ToFileAccess();
FileMode fileMode;
if ((mode & IOMode.CreateIfNotExists) != 0) {
if ((mode & IOMode.ErrorIfExists) != 0) {
access |= FileAccess.Write;
fileMode = FileMode.CreateNew;
} else {
fileMode = FileMode.OpenOrCreate;
}
} else {
fileMode = FileMode.Open;
}
if ((mode & IOMode.Truncate) != 0 && (access & FileAccess.Write) == 0) {
throw RubyExceptions.CreateEINVAL("cannot truncate a file opened for reading only");
}
if ((mode & IOMode.WriteAppends) != 0 && (access & FileAccess.Write) == 0) {
throw RubyExceptions.CreateEINVAL("cannot append to a file opened for reading only");
}
if (String.IsNullOrEmpty(path)) {
throw RubyExceptions.CreateEINVAL();
}
Stream stream;
if (path == "NUL") {
stream = Stream.Null;
} else {
try {
stream = context.DomainManager.Platform.OpenInputFileStream(path, fileMode, access, FileShare.ReadWrite);
} catch (FileNotFoundException) {
throw RubyExceptions.CreateENOENT(String.Format("No such file or directory - {0}", path));
} catch (DirectoryNotFoundException e) {
throw RubyExceptions.CreateENOENT(e.Message, e);
} catch (PathTooLongException e) {
throw RubyExceptions.CreateENOENT(e.Message, e);
} catch (IOException) {
if ((mode & IOMode.ErrorIfExists) != 0) {
throw RubyExceptions.CreateEEXIST(path);
} else {
throw;
}
} catch (ArgumentException e) {
throw RubyExceptions.CreateEINVAL(e.Message, e);
}
}
if ((mode & IOMode.Truncate) != 0) {
stream.SetLength(0);
}
return stream;
}
示例4: RubyIO
public RubyIO(RubyContext/*!*/ context, Stream/*!*/ stream, int descriptor, IOMode mode)
: this(context)
{
ContractUtils.RequiresNotNull(context, "context");
ContractUtils.RequiresNotNull(stream, "stream");
SetStream(stream);
_mode = mode;
_fileDescriptor = descriptor;
}
示例5: CheckContent
private static MutableString/*!*/ CheckContent(MutableString/*!*/ content, IOMode mode) {
if (content.IsFrozen && mode.CanWrite()) {
throw Errno.CreateEACCES("Permission denied");
}
if ((mode & IOMode.Truncate) != 0) {
content.Clear();
}
return content;
}
示例6: RubyInputProvider
internal RubyInputProvider(RubyContext/*!*/ context, ICollection<string>/*!*/ arguments, RubyEncoding/*!*/ encoding) {
Assert.NotNull(context, encoding);
Assert.NotNullItems(arguments);
_context = context;
var args = new RubyArray();
foreach (var arg in arguments) {
ExpandArgument(args, arg, encoding);
}
_commandLineArguments = args;
_lastInputLineNumber = 1;
_currentFileIndex = -1;
_singleton = new object();
_defaultMode = IOMode.ReadOnly;
}
示例7: RubyFile
public RubyFile(RubyContext/*!*/ context, Stream/*!*/ stream, int descriptor, IOMode mode)
: base(context, stream, descriptor, mode) {
_path = null;
}
示例8: Reset
public void Reset(Stream/*!*/ stream, IOMode mode) {
_mode = mode;
SetStream(stream);
SetFileDescriptor(Context.AllocateFileDescriptor(stream));
}
示例9: BuildParameterList
private List<Parameter> BuildParameterList(List<string> identifierList, TypeRecord variableType,
IOMode ioMode,List<Parameter> parameterList)
{
foreach (string name in identifierList)
{
parameterList.Add(new Parameter(name,ioMode, variableType.variableType,1));
}
return parameterList;
}
示例10: OpenPipe
public static RubyIO/*!*/ OpenPipe(
RubyContext/*!*/ context,
MutableString/*!*/ command,
IOMode mode) {
bool redirectStandardInput = mode.CanWrite();
bool redirectStandardOutput = mode.CanRead();
Process process = RubyProcess.CreateProcess(context, command, redirectStandardInput, redirectStandardOutput, false);
StreamReader reader = null;
StreamWriter writer = null;
if (redirectStandardOutput) {
reader = process.StandardOutput;
}
if (redirectStandardInput) {
writer = process.StandardInput;
}
return new RubyIO(context, reader, writer, mode);
}
示例11: CheckOpenPipe
private static RubyIO CheckOpenPipe(RubyContext/*!*/ context, MutableString path, IOMode mode) {
string fileName = path.ConvertToString();
if (fileName.Length > 0 && fileName[0] == '|') {
#if SILVERLIGHT
throw new NotSupportedException("open cannot create a subprocess");
#else
if (fileName.Length > 1 && fileName[1] == '-') {
throw new NotImplementedError("forking a process is not supported");
}
return RubyIOOps.OpenPipe(context, path.GetSlice(1), (IOMode)mode);
#endif
}
return null;
}
示例12: StringIO
public StringIO(MutableString/*!*/ content, IOMode mode) {
ContractUtils.RequiresNotNull(content, "content");
_content = content;
_mode = mode;
}
示例13: IsReadable
public static bool IsReadable(IOMode mode) {
return (mode == IOMode.ReadOnlyFromStart ||
mode == IOMode.ReadWriteAppend ||
mode == IOMode.ReadWriteFromStart ||
mode == IOMode.ReadWriteTruncate);
}
示例14: RubyFile
public RubyFile(RubyContext/*!*/ context, MutableString/*!*/ path, IOMode mode)
: this(context, context.DecodePath(path), mode) {
}
示例15: Write
public override void Write(bool state)
{
Mode = IOMode.Output;
_port.Write(state);
}