Beispiel #1
0
        private static string TryParseFolder(string path, bool exists)
        {
            string realPath = path;

            if (path.StartsWith(PMFAT.CurrentDirectory))
            {
                realPath = path;
            }
            else if (path.StartsWith(@"0:\"))
            {
                realPath = path;
            }
            else if (!path.StartsWith(PMFAT.CurrentDirectory) && !path.StartsWith(@"0:\"))
            {
                realPath = PMFAT.CurrentDirectory + path;
            }
            if (exists)
            {
                if (PMFAT.FolderExists(realPath))
                {
                    return(realPath);
                }
                else
                {
                    return("*ERROR");
                }
            }
            else
            {
                return(realPath);
            }
        }
Beispiel #2
0
        public override void Execute(string line, string[] args)
        {
            // show contents of active directory
            if (args.Length == 1)
            {
                ListContents(PMFAT.CurrentDirectory);
            }
            // show contents of specified directory
            else if (line.Length > 4)
            {
                // parse path
                string path = line.Substring(4, line.Length - 4).ToLower();
                if (path.EndsWith('\\'))
                {
                    path = path.Remove(path.Length - 1, 1);
                }
                path += "\\";

                if (PMFAT.FolderExists(path))
                {
                    if (path.StartsWith(PMFAT.CurrentDirectory))
                    {
                        ListContents(path);
                    }
                    else if (path.StartsWith(@"0:\"))
                    {
                        ListContents(path);
                    }
                    else if (!path.StartsWith(PMFAT.CurrentDirectory) && !path.StartsWith(@"0:\"))
                    {
                        if (PMFAT.FolderExists(PMFAT.CurrentDirectory + path))
                        {
                            ListContents(PMFAT.CurrentDirectory + path);
                        }
                        else
                        {
                            CLI.WriteLine("Could not locate directory \"" + path + "\"", Color.Red);
                        }
                    }
                    else
                    {
                        CLI.WriteLine("Could not locate directory \"" + path + "\"", Color.Red);
                    }
                }
                else
                {
                    CLI.WriteLine("Could not locate directory!", Color.Red);
                }
            }
            else
            {
                CLI.WriteLine("Invalid argument! Path expected.", Color.Red);
            }
        }
Beispiel #3
0
        public override void Execute(string line, string[] args)
        {
            if (args.Length == 1)
            {
                PMFAT.CurrentDirectory = @"0:\";
            }
            else
            {
                if (line.Length > 3)
                {
                    string path = line.Substring(3, line.Length - 3).ToLower();
                    if (path.EndsWith('\\'))
                    {
                        path = path.Remove(path.Length - 1, 1);
                    }
                    path += "\\";

                    if (PMFAT.FolderExists(path))
                    {
                        if (path.StartsWith(PMFAT.CurrentDirectory))
                        {
                            PMFAT.CurrentDirectory = path;
                        }
                        else if (path.StartsWith(@"0:\"))
                        {
                            PMFAT.CurrentDirectory = path;
                        }
                        else if (!path.StartsWith(PMFAT.CurrentDirectory) && !path.StartsWith(@"0:\"))
                        {
                            if (PMFAT.FolderExists(PMFAT.CurrentDirectory + path))
                            {
                                PMFAT.CurrentDirectory = PMFAT.CurrentDirectory + path;
                            }
                            else
                            {
                                CLI.WriteLine("Could not locate directory \"" + path + "\"", Color.Red);
                            }
                        }
                    }
                    else
                    {
                        CLI.WriteLine("Could not locate directory!", Color.Red);
                    }
                }
                else
                {
                    CLI.WriteLine("Invalid argument! Path expected.", Color.Red);
                }
            }
        }