Exemple #1
0
        } // proc write

        /// <summary></summary>
        /// <returns></returns>
        public LuaFile tmpfile()
        {
            if (tempFile == null)
            {
                tempFile = tmpfilenew();
            }
            return(tempFile);
        } // func read
Exemple #2
0
        }         // 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
Exemple #3
0
		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
Exemple #4
0
        } // 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
Exemple #5
0
        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
Exemple #6
0
        } // 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
Exemple #7
0
        } // 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
Exemple #8
0
        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
Exemple #9
0
    } // proc write

    /// <summary></summary>
    /// <returns></returns>
    public LuaFile tmpfile()
    {
      if (tempFile == null)
        tempFile = tmpfilenew();
      return tempFile;
    } // func read
Exemple #10
0
    } // 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
Exemple #11
0
    } // 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