Ejemplo n.º 1
0
                public void Execute(string input)
                {
                    List <string> result = Parse(input);

                    if (result.Count == 1)
                    {
                        MainSystem.Execute(MainSession, result[0]);
                    }
                    else if (result.Count > 1)
                    {
                        string args    = "";
                        string operand = null;
                        string args2   = "";
                        args = result[0];
                        if (result.Count >= 3)
                        {
                            operand = result[1];
                            args2   = result[2];
                        }

                        if (args2.Length == 0)
                        {
                            MainSystem.Execute(MainSession, args);
                        }
                        else
                        {
                            if (operand == ">" || operand == "<")
                            {
                                NixPath filePath = new NixPath(args2);
                                NixPath path     = OpenPath(filePath);
                                using (Stream fstream = MainSystem.RootDrive.OpenFile(path, FileAccess.Write, FileMode.Create))
                                {
                                    if (operand == ">")
                                    {
                                        MainSystem.Execute(MainSession, args, fstream, null);
                                    }
                                    else if (operand == "<")
                                    {
                                        MainSystem.Execute(MainSession, args, null, fstream);
                                    }
                                }
                            }
                            else if (operand == "|")
                            {
                                NixStream tmp = new NixStream();
                                MainSystem.Execute(MainSession, args, tmp, null);
                                MainSystem.Execute(MainSession, args2, null, tmp);
                            }
                        }
                    }
                }