static public FILE *fopen(string FileName, string Format) { var file = (FILE *)CAlloc.malloc(sizeof(FILE)); Stream Stream; var BaseFormat = Format[0]; var Binary = Format.Substring(1).Contains('b'); var Plus = Format.Substring(1).Contains('+'); var StreamFileShare = FileShare.Read; switch (BaseFormat) { case 'r': Stream = File.Open(FileName, FileMode.Open, Plus ? FileAccess.ReadWrite : FileAccess.Read, StreamFileShare); break; case 'w': Stream = File.Open(FileName, FileMode.Create, Plus ? FileAccess.ReadWrite : FileAccess.Write, StreamFileShare); break; case 'a': Stream = File.Open(FileName, FileMode.Append, Plus ? FileAccess.ReadWrite : FileAccess.Write, StreamFileShare); break; default: throw(new Exception(String.Format("Unknown base file format '{0}' : '{1}'", BaseFormat, Format))); } file->SetStream(Stream); return(file); }
static public FILE *CreateForStream(Stream Stream) { var File = (FILE *)CAlloc.malloc(sizeof(FILE)); File->SetStream(Stream); return(File); }