} // proc write /// <summary></summary> /// <returns></returns> public LuaFile tmpfile() { if (tempFile == null) { tempFile = tmpfilenew(); } return(tempFile); } // func read
} // proc input /// <summary></summary> /// <param name="file"></param> /// <returns></returns> public LuaFile output(object file = null) { if (file is string) { defaultOutput?.close(); defaultOutput = LuaFileStream.OpenFile((string)file, "w", defaultEncoding); return(defaultOutput); } else if (file is LuaFile) { defaultOutput?.close(); defaultOutput = (LuaFile)file; } return(defaultOutput); } // proc output
public LuaLinesEnumerator(LuaFile file, bool lCloseOnEnd, object[] args, int iStartIndex) { this.file = file; this.lCloseOnEnd = lCloseOnEnd; this.returns = null; this.iReturnIndex = 0; if (iStartIndex > 0) { this.args = new object[args.Length - iStartIndex]; if (args.Length > 0) Array.Copy(args, iStartIndex, this.args, 0, this.args.Length); } else this.args = args; } // ctor
} // func lines /// <summary></summary> /// <param name="file"></param> /// <returns></returns> public LuaResult close(LuaFile file = null) { if (file != null) { return(file.close()); } else if (defaultOutput != null) { LuaResult r = defaultOutput.close(); defaultOutput = null; return(r); } else { return(null); } } // proc close
public LuaLinesEnumerator(LuaFile file, bool lCloseOnEnd, object[] args, int iStartIndex) { this.file = file; this.lCloseOnEnd = lCloseOnEnd; this.returns = null; this.iReturnIndex = 0; if (iStartIndex > 0) { this.args = new object[args.Length - iStartIndex]; if (args.Length > 0) { Array.Copy(args, iStartIndex, this.args, 0, this.args.Length); } } else { this.args = args; } } // ctor
} // proc close /// <summary></summary> /// <param name="file"></param> /// <returns></returns> public LuaFile input(object file = null) { if (file is string) { if (defaultInput != null) { defaultInput.close(); } defaultInput = LuaFileStream.OpenFile((string)file, "r", defaultEncoding); return(defaultInput); } else if (file is LuaFile) { if (defaultInput != null) { defaultInput.close(); } defaultInput = (LuaFile)file; } return(defaultInput); } // proc input
} // proc input /// <summary></summary> /// <param name="file"></param> /// <returns></returns> public LuaFile output(object file = null) { if (file is string) { if (defaultOutput != null) { defaultOutput.close(); } defaultOutput = new LuaFile((string)file, "w"); return(defaultOutput); } else if (file is LuaFile) { if (defaultOutput != null) { defaultOutput.close(); } defaultOutput = (LuaFile)file; } return(defaultOutput); } // proc output
private static LuaFile InOutOpen(object file, Encoding defaultEncoding, ref LuaFile fileVar) { switch (file) { case string fileName: fileVar?.close(); fileVar = LuaFileStream.OpenFile(fileName, "w", defaultEncoding); break; case LuaFile handle: if (handle == defaultInOut.Value) { fileVar = null; } else { fileVar?.close(); fileVar = handle; } break; } return(fileVar ?? defaultInOut.Value); } // func InOutOpen
} // proc write /// <summary></summary> /// <returns></returns> public LuaFile tmpfile() { if (tempFile == null) tempFile = tmpfilenew(); return tempFile; } // func read
} // proc input /// <summary></summary> /// <param name="file"></param> /// <returns></returns> public LuaFile output(object file = null) { if (file is string) { if (defaultOutput != null) defaultOutput.close(); defaultOutput = LuaFileStream.OpenFile((string)file, "w", defaultEncoding); return defaultOutput; } else if (file is LuaFile) { if (defaultOutput != null) defaultOutput.close(); defaultOutput = (LuaFile)file; } return defaultOutput; } // proc output
} // func lines /// <summary></summary> /// <param name="file"></param> /// <returns></returns> public LuaResult close(LuaFile file = null) { if (file != null) return file.close(); else if (defaultOutput != null) { LuaResult r = defaultOutput.close(); defaultOutput = null; return r; } else return null; } // proc close