コード例 #1
0
ファイル: Functions.Utils.cs プロジェクト: ammogcoder/mobile
        protected override Variable Evaluate(ParsingScript script)
        {
            List <string> patterns = Utils.GetFunctionArgs(script);

            if (patterns.Count == 0)
            {
                patterns.Add("*.*");
            }

            List <Variable> results = null;

            try
            {
                string        pwd   = Directory.GetCurrentDirectory();
                List <string> files = Utils.GetFiles(pwd, patterns.ToArray());

                results = Utils.ConvertToResults(files.ToArray(), true);
            }
            catch (Exception exc)
            {
                throw new ArgumentException("Couldn't list directory: " + exc.Message);
            }

            return(new Variable(results));
        }
コード例 #2
0
        protected override Parser.Result Evaluate(string data, ref int from)
        {
            List <string> patterns = Utils.GetFunctionArgs(data, ref from);

            if (patterns.Count == 0)
            {
                patterns.Add("*.*");
            }

            List <Parser.Result> results = null;

            try
            {
                string        pwd   = Directory.GetCurrentDirectory();
                List <string> files = Utils.GetFiles(pwd, patterns.ToArray());

                //m_interpreter.AppendOutput("----- Found files with pattern [" +
                //                           string.Join(", ", patterns.ToArray()) + "] -----");
                results = new List <Parser.Result>(files.Count);
                foreach (string filename in files)
                {
                    results.Add(new Parser.Result(Double.NaN, filename));
                    //m_interpreter.AppendOutput(filename);
                }

                //m_interpreter.AppendOutput(Utils.GetLine());
            }
            catch (Exception exc)
            {
                throw new ArgumentException("Couldn't list directory: " + exc.Message);
            }

            return(new Parser.Result(Double.NaN, null, results));
        }