Beispiel #1
0
        protected override IEnumerator InnerExecute()
        {
            yield return(null);

            if (HelpOrUnknownParameters(true))
            {
                yield break;
            }

            var fileSystem = DeviceCollection.FileSystem;

            ProgramParameter.Param param;
            if (Parameters.TryGetParam("c", out param))
            {
                var path = param.Value;

                Directory dir;
                var       result = fileSystem.CreateDiretory(path, out dir);

                if (result == FileSystem.OperationResult.DuplicatedName)
                {
                    Alias.Term.ShowText("There already is a directory with this name");
                }
            }
            else if (Parameters.TryGetParam("", out param))
            {
                var dir = fileSystem.FindDirectory(param.Value, true);
                if (dir == null)
                {
                    File file;
                    fileSystem.FindFileByPath(param.Value, out file);
                    if (file != null)
                    {
                        Alias.Term.ShowText(TextBuilder.WarningText("This is a file. Use \"read\" command to read it."));
                    }
                    else
                    {
                        Alias.Term.ShowText(TextBuilder.WarningText("Directory not found."));
                    }
                }
            }
            else if (param == null)
            {
                var dir = fileSystem.CurrentDirectory;
                ProgramUtil.ShowFiles(dir);
                yield return(0);

                Alias.Term.RepositionText();
            }
        }