コード例 #1
0
        protected override bool CheckParameterValues(IOutputter outputter)
        {
            if (GetParameters().Count > 0)
            {
                string         dirPath = GetParameters()[0];
                FileSystemItem fs      = Drive.GetItemFromPath(dirPath);
                if (fs == null)
                {
                    outputter.PrintLine("File Not Found");
                    return(false);
                }

                if (fs.IsDirectory() == false)
                {
                    dirToPrint = fs.Parent;
                }
                else
                {
                    dirToPrint = (Directory)fs;
                }
            }
            else
            {
                dirToPrint = Drive.CurrentDirectory;
            }

            return(true);
        }
コード例 #2
0
ファイル: DirectoryTest.cs プロジェクト: ryonoha/DOSBox.cs
        public void Content_Subdirectory_ParentIsSetCorrectly()
        {
            FileSystemItem item   = rootDir.Content.ElementAt(0);
            FileSystemItem parent = item.Parent;

            Assert.IsTrue(parent.IsDirectory());
            Assert.AreSame(this.rootDir, parent);
        }
コード例 #3
0
ファイル: DirectoryTest.cs プロジェクト: ryonoha/DOSBox.cs
        public void Content_Subdirectory_Element0HasCorrectName()
        {
            FileSystemItem item = rootDir.Content.ElementAt(0);

            Assert.IsTrue(item.IsDirectory());
            Assert.AreEqual(subDir1.Name, item.Name);
            Assert.AreSame(this.subDir1, item);
        }
コード例 #4
0
        public static Directory GetDirectory(IDrive drive, string directoryPath, string directoryName)
        {
            FileSystemItem fileSystemItem = drive.GetItemFromPath(directoryPath);

            Assert.IsNotNull(fileSystemItem);
            Assert.AreEqual(directoryName, fileSystemItem.Name);
            Assert.IsTrue(fileSystemItem.IsDirectory());
            return((Directory)fileSystemItem);
        }
コード例 #5
0
        public static File GetFile(IDrive drive, string filePath, string fileName)
        {
            FileSystemItem fileSystemItem = drive.GetItemFromPath(filePath + "\\" + fileName);

            Assert.IsNotNull(fileSystemItem);
            Assert.AreEqual(fileName, fileSystemItem.Name);
            Assert.IsFalse(fileSystemItem.IsDirectory());
            return((File)fileSystemItem);
        }
コード例 #6
0
ファイル: CmdCd.cs プロジェクト: nemccarthy/DosBox
        public override void Execute(IOutputter outputter)
        {
            bool retVal = false;

            // cd without parameters
            if (newDirectoryName == null)
            {
                outputter.PrintLine(Drive.CurrentDirectory.Path);
                return;
            }

            // cd with parameters: Check if passed directory is valid before change to this directory
            FileSystemItem newDir = Drive.GetItemFromPath(newDirectoryName);

            if (newDir == null)
            {
                outputter.PrintLine(SYSTEM_CANNOT_FIND_THE_PATH_SPECIFIED);
                return;
            }

            if (newDir.IsDirectory() == false)
            {
                outputter.PrintLine(SYSTEM_CANNOT_FIND_THE_PATH_SPECIFIED);
                return;
            }

            if (Drive.GetItemFromPath(newDir.Path) != newDir)
            {
                outputter.PrintLine("Path not in drive " + Drive.DriveName);
                return;
            }

            if (newDir.IsDirectory())
            {
                retVal = Drive.ChangeCurrentDirectory((Directory)newDir);
            }

            if (retVal == false)
            {
                outputter.PrintLine(SYSTEM_CANNOT_FIND_THE_PATH_SPECIFIED);
            }
        }
コード例 #7
0
ファイル: CmdType.cs プロジェクト: igustiawan/SCRUM-DOSBOX
        private Directory CheckAndPreparePathParameter(string pathName, IOutputter outputter)
        {
            FileSystemItem fsi = Drive.GetItemFromPath(pathName);

            if (fsi == null)
            {
                outputter.PrintLine(SYSTEM_CANNOT_FIND_THE_PATH_SPECIFIED);
                return(null);
            }
            if (!fsi.IsDirectory())
            {
                return(fsi.Parent);
            }
            if (fsi.IsDirectory())
            {
                outputter.PrintLine(ACCESS_DENIED);
                return(null);
            }
            return((Directory)fsi);
        }
コード例 #8
0
ファイル: DriveTest.cs プロジェクト: ryonoha/DOSBox.cs
        public void testSingleCharacterDirectories()
        {
            Assert.IsTrue(rootDir.GetNumberOfContainedDirectories() == 2);

            var newDir = new Directory("N");

            rootDir.Add(newDir);
            Assert.IsTrue(rootDir.GetNumberOfContainedDirectories() == 3);

            FileSystemItem item = drive.GetItemFromPath(rootDir.Path + "\\N");

            Assert.IsNotNull(item);
            Assert.IsTrue(item.IsDirectory());
            Assert.AreSame(item, newDir);
        }
コード例 #9
0
        private static Directory ExtractAndCheckIfValidDirectory(string destinationDirectoryName, IDrive drive, IOutputter outputter)
        {
            FileSystemItem tempDestinationDirectory = drive.GetItemFromPath(destinationDirectoryName);

            if (tempDestinationDirectory == null)
            {
                outputter.PrintLine(SYSTEM_CANNOT_FIND_THE_PATH_SPECIFIED);
                return(null);
            }
            if (!tempDestinationDirectory.IsDirectory())
            {
                outputter.PrintLine(DESTINATION_IS_FILE);
                return(null);
            }
            return((Directory)tempDestinationDirectory);
        }
コード例 #10
0
        public static Directory ExtractAndCheckIfValidDirectory(string destinationDirectoryName, IDrive drive, IOutputter outputter)
        {
            FileSystemItem tempDestinationDirectory = drive.GetItemFromPath(destinationDirectoryName);

            if (tempDestinationDirectory == null)
            {
                outputter.PrintLine(NO_IS_FILE + destinationDirectoryName);
                return(null);
            }
            if (!tempDestinationDirectory.IsDirectory())
            {
                outputter.PrintLine(DESTINATION_IS_FILE);
                return(null);
            }
            return((Directory)tempDestinationDirectory);
        }
コード例 #11
0
        public void testSubDirectory()
        {
            List <FileSystemItem> content = rootDir.Content;

            Assert.IsTrue(content != null);
            Assert.IsTrue(content.Count == 2);

            FileSystemItem item = content[0];

            Assert.IsTrue(item.IsDirectory());
            Assert.IsTrue(item.Name.CompareTo(subDir1.Name) == 0);

            FileSystemItem parent = item.Parent;

            Assert.IsTrue(parent.IsDirectory());
            Assert.AreSame(parent, rootDir);

            Assert.IsTrue(parent.Parent == null);

            string path = item.Path;

            Assert.IsTrue(path.CompareTo(rootDir.Name + "\\" + subDir1.Name) == 0);
        }