Пример #1
0
        protected override Variable Evaluate(ParsingScript script)
        {
            string        search   = Utils.GetStringOrVarValue(script);
            List <string> patterns = Utils.GetFunctionArgs(script);

            bool ignoreCase = true;

            if (patterns.Count > 0 && patterns.Last().Equals("case"))
            {
                ignoreCase = false;
                patterns.RemoveAt(patterns.Count - 1);
            }
            if (patterns.Count == 0)
            {
                patterns.Add("*.*");
            }

            List <Variable> results = null;

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

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

            return(new Variable(results));
        }
Пример #2
0
        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));
        }
Пример #3
0
        protected override Variable Evaluate(ParsingScript script)
        {
            string filename = Utils.GetItem(script).AsString();

            string[] lines = Utils.GetFileLines(filename);

            List <Variable> results = Utils.ConvertToResults(lines);

            return(new Variable(results));
        }
Пример #4
0
        protected override Variable Evaluate(ParsingScript script)
        {
            string filename = Utils.GetStringOrVarValue(script);

            string[] lines = Utils.GetFileLines(filename);

            List <Variable> results = Utils.ConvertToResults(lines);

            Interpreter.Instance.AppendOutput("Read " + lines.Length + " line(s).", true);

            return(new Variable(results));
        }
Пример #5
0
        protected override Variable Evaluate(ParsingScript script)
        {
            string filename = Utils.GetItem(script).AsString();

            byte[] bytes = Utils.GetFileBytes(filename);

            List <Variable> results = Utils.ConvertToResults(bytes);

            Interpreter.Instance.AppendOutput("Read " + bytes.Length + " byte(s).", true);

            return(new Variable(results));
        }
Пример #6
0
        protected override Variable Evaluate(ParsingScript script)
        {
            string filename = Utils.GetStringOrVarValue(script);
            int    size     = Constants.DEFAULT_FILE_LINES;

            bool sizeAvailable = Utils.SeparatorExists(script);

            if (sizeAvailable)
            {
                Variable length = Utils.GetItem(script);
                Utils.CheckPosInt(length);
                size = (int)length.Value;
            }

            string[]        lines   = Utils.GetFileLines(filename, -1, size);
            List <Variable> results = Utils.ConvertToResults(lines);

            return(new Variable(results));
        }