Пример #1
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));
                }
            }
Пример #2
0
            public override void Execute(FileSysEmulator fse)
            {
                FileSysEmulator.FileSystemItem srcItem = _sourcePath.Resolved.ResolvedFsi;
                if ((srcItem is FileSysEmulator.FsLink) || (srcItem is FileSysEmulator.FsDir) || (srcItem is FileSysEmulator.FsFile))
                {
                    FileSysEmulator.FileSystemItem dst = _destPath.Resolved.ResolvedFsi;
                    if (dst is FileSysEmulator.FsLink)
                    {
                        dst = fse.GetTargetItemOfLink((FileSysEmulator.FsLink)dst);
                    }
                    if (!(dst is FileSysEmulator.FsContainer))
                    {
                        throw new ApplicationException(String.Format("Can't copy '{0}' to '{1}.'", srcItem.GetFullPath(), dst.GetFullPath()));
                    }

                    FileSysEmulator.FsContainer parent       = (FileSysEmulator.FsContainer)srcItem.Parent;
                    FileSysEmulator.FsContainer dstContainer = (FileSysEmulator.FsContainer)dst;
                    if ((FileSysEmulator.FsContainer)srcItem.Parent == dstContainer)
                    {
                        throw new ApplicationException(String.Format("Can't copy the '{0}' over itself.", srcItem.GetFullPath()));
                    }

                    fse.StartCopying(srcItem);
                    parent.CopyItem(srcItem, dstContainer);
                    fse.EndCopying();
                }
                else
                {
                    throw new ApplicationException(String.Format("Can't copy the '{0}'.", srcItem.GetFullPath()));
                }
            }
Пример #3
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);
            }
Пример #4
0
            public override void Execute(FileSysEmulator fse)
            {
                FileSysEmulator.FileSystemItem item = _newCurrDir.Resolved.ResolvedFsi;
                if (item is FileSysEmulator.FsLink)
                {
                    item = fse.GetTargetItemOfLink((FileSysEmulator.FsLink)item);
                }

                fse.CurrentDrive = item.GetParentDrive();
                if (item is FileSysEmulator.FsDir)
                {
                    fse.CurrentDrive.CurrentDir = (FileSysEmulator.FsDir)item;
                }
                else if (item is FileSysEmulator.FsDrive)
                {
                    fse.CurrentDrive.CurrentDir = null;
                }
            }
Пример #5
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("\\", ""));
                }
            }
Пример #6
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);
            }
Пример #7
0
            public override void Execute(FileSysEmulator fse)
            {
                FileSysEmulator.FileSystemItem dirWhere = _pathWhereToMake.Resolved.ResolvedFsi;

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

                if (dirWhere is FileSysEmulator.FsDir)
                {
                    ((FileSysEmulator.FsDir)dirWhere).AddFile(_fileName.Arg);
                }
                else if (dirWhere is FileSysEmulator.FsDrive)
                {
                    ((FileSysEmulator.FsDrive)dirWhere).AddFile(_fileName.Arg);
                }
                else
                {
                    throw new ApplicationException(String.Format("Can't create file '{0}' in '{1}'.", _fileName.Arg, dirWhere.ToString()));
                }
            }