예제 #1
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
예제 #2
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
예제 #3
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
예제 #4
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 = new LuaFile((string)file, "r");

                return(defaultInput);
            }
            else if (file is LuaFile)
            {
                if (defaultInput != null)
                {
                    defaultInput.close();
                }
                defaultInput = (LuaFile)file;
            }
            return(defaultInput);
        } // proc input
예제 #5
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
예제 #6
0
파일: LuaFile.cs 프로젝트: hdkeeper/neolua
        }         // ctor

        public bool MoveNext()
        {
            if (file.IsClosed || file.TextReader.EndOfStream)
            {
                if (lCloseOnEnd)
                {
                    file.close();
                }
                return(false);
            }
            else
            {
                iReturnIndex++;
                if (returns == null || iReturnIndex >= returns.Length)                 // read returns
                {
                    iReturnIndex = 0;
                    returns      = file.read(args);
                }
                return(true);
            }
        }         // func MoveNext
예제 #7
0
        }         // ctor

        public bool MoveNext()
        {
            if (file.IsClosed)
            {
                if (closeOnEnd)
                {
                    file.close();
                }
                return(false);
            }
            else
            {
                returnIndex++;
                if (returns == null || returnIndex >= returns.Length)                 // read returns
                {
                    returnIndex = 0;
                    returns     = file.read(args);
                }
                return(true);
            }
        }         // func MoveNext
예제 #8
0
파일: LuaFile.cs 프로젝트: edisonh/neolua
    } // 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