Ejemplo n.º 1
0
            public override void Execute(FileSysEmulator fse)
            {
                FileSysEmulator.FileSystemItem item = _treeToRemove.Resolved.ResolvedFsi;
                if (item is FileSysEmulator.FsLink)
                {
                    item = fse.GetTargetItemOfLink((FileSysEmulator.FsLink)item);
                }

                if (item is FileSysEmulator.FsDrive)
                {
                    throw new ApplicationException(String.Format("Can't remove '{0}'.", item.GetFullPath()));
                }

                FileSysEmulator.FsDir dir = (FileSysEmulator.FsDir)item;

                if (fse.CurrentDrive.CurrentDir != null)
                {
                    FileSysEmulator.FileSystemItem drT = fse.CurrentDrive.CurrentDir;
                    Boolean found = false;
                    for ( ; drT != null && !(drT is FileSysEmulator.FsRoot); drT = drT.Parent)
                    {
                        if (drT == dir)
                        {
                            found = true; break;
                        }
                    }
                    if (found)
                    {
                        throw new ApplicationException(String.Format("Can't remove '{0}' with subtree because it contains the current directory.", item.GetFullPath()));
                    }
                }

                fse.RemoveItem(item);
            }
Ejemplo n.º 2
0
            public override void Execute(FileSysEmulator fse)
            {
                FileSysEmulator.FileSystemItem itemLinkTo = _sourcePath.Resolved.ResolvedFsi;
                if (itemLinkTo is FileSysEmulator.FsLink)
                {
                    throw new ApplicationException("Can't create link to link.");
                }

                FileSysEmulator.FileSystemItem targetContainer = _destPath.Resolved.ResolvedFsi;
                if (targetContainer is FileSysEmulator.FsLink)
                {
                    targetContainer = fse.GetTargetItemOfLink((FileSysEmulator.FsLink)targetContainer);
                }

                if (targetContainer is FileSysEmulator.FsDir)
                {
                    FileSysEmulator.FsDir dir = (FileSysEmulator.FsDir)targetContainer;
                    dir.AddLink(itemLinkTo, true);
                }
                else if (targetContainer is FileSysEmulator.FsDrive)
                {
                    FileSysEmulator.FsDrive drv = (FileSysEmulator.FsDrive)targetContainer;
                    drv.AddLink(itemLinkTo, true);
                }
                else
                {
                    throw new ApplicationException(String.Format("Unsupported link target '{0}'.", targetContainer.GetType().Name));
                }
            }
Ejemplo n.º 3
0
            public override void Execute(FileSysEmulator fse)
            {
                FileSysEmulator.FileSystemItem item = _targetDir.Resolved.ResolvedFsi;

                if (item is FileSysEmulator.FsLink)
                {
                    item = fse.GetTargetItemOfLink((FileSysEmulator.FsLink)item);
                }

                if (item is FileSysEmulator.FsDrive)
                {
                    FileSysEmulator.FsDrive drv = (FileSysEmulator.FsDrive)item;
                    drv.AddDir(_newSubDir.Arg.Replace("\\", ""));
                }
                else
                {
                    FileSysEmulator.FsDir dir = (FileSysEmulator.FsDir)item;
                    dir.AddDir(_newSubDir.Arg.Replace("\\", ""));
                }
            }
Ejemplo n.º 4
0
            public override void Execute(FileSysEmulator fse)
            {
                FileSysEmulator.FileSystemItem item = _dirPath.Resolved.ResolvedFsi;
                if (item is FileSysEmulator.FsLink)
                {
                    item = fse.GetTargetItemOfLink((FileSysEmulator.FsLink)item);
                }

                FileSysEmulator.FsDir dir = (FileSysEmulator.FsDir)item;
                if (!dir.IsEmpty)
                {
                    throw new ApplicationException(String.Format("Can't remove '{0}' because it isn't empty.", item.GetFullPath()));
                }
                if (dir == fse.CurrentDrive.CurrentDir)
                {
                    throw new ApplicationException(String.Format("Can't remove '{0}' because it is current.", item.GetFullPath()));
                }

                fse.RemoveItem(item);
            }
Ejemplo n.º 5
0
        public void Resolve(FileSysEmulator fse)
        {
            FileSysEmulator.FsDrive currDrv = fse.CurrentDrive;
            if (currDrv == null)
            {
                throw new ApplicationException(String.Format("Can't resolve path '{0}': there isn't current drive.", ToString()));
            }

            _resolved = (ArgInfo)this.MemberwiseClone();
            _resolved._locationSteps = new String[0];

            if (_drive.Length == 0)
            {
                _resolved._drive = currDrv.Name;
            }

            if (_relativity == PathType.RelativeToDir || _relativity == PathType.RelativeToDriveDir)
            {
                _resolved._relativity = PathType.RelativeToDriveRoot;
                FileSysEmulator.FsDir currDir = currDrv.CurrentDir;
                if (currDir != null)
                {
                    List <String> lst = currDir.GetLocationSteps(false);
                    lst.AddRange(_locationSteps);
                    _resolved._locationSteps = lst.ToArray();
                }
                else
                {
                    _resolved._locationSteps = _locationSteps;
                }
            }
            else
            {
                _resolved._locationSteps = _locationSteps;
            }


            _resolved._arg = _resolved.GetFullPath();
        }