Beispiel #1
0
        static ArgInfo()
        {
            ArgInfo res = new ArgInfo();

            res._arg            = String.Empty;
            res._relativity     = PathType.RelativeToDir;
            res._pathTarget     = TargetType.Dir;
            _currDirOfCurrDrive = res;
        }
Beispiel #2
0
            protected override void Construct()
            {
                _targetDir = _arguments[0];
                if (_targetDir.Steps.Length == 0)
                {
                    throw new ApplicationException(String.Format("Can't create directory '{0}'. Name is missing.", _targetDir.Arg));
                }

                _targetDir.SeparateLastStep(out _newSubDir, ArgInfo.TargetType.Dir, ArgInfo.TargetType.Dir);
            }
Beispiel #3
0
            protected override void Construct()
            {
                _pathWhereToMake = _arguments[0];
                if (_pathWhereToMake.Steps.Length == 0)
                {
                    throw new ApplicationException(String.Format("Can't create a file '{0}'. Name is missing.", _pathWhereToMake.Arg));
                }

                _pathWhereToMake.SeparateLastStep(out _fileName, ArgInfo.TargetType.Dir, ArgInfo.TargetType.File);
            }
Beispiel #4
0
 protected override void Construct()
 {
     _sourcePath = _arguments[0];
     if (_arguments.Length == 2)
     {
         _destPath = _arguments[1];
     }
     else
     {
         _destPath = ArgInfo.CurrDirOfCurrDrive;
     }
 }
Beispiel #5
0
        public void SeparateLastStep(out ArgInfo ai, TargetType pathTargetLeft, TargetType pathTargetRight)
        {
            ai                = new ArgInfo();
            ai._relativity    = PathType.RelativeToDir;
            ai._pathTarget    = pathTargetRight;
            ai._arg           = _locationSteps[_locationSteps.Length - 1];
            ai._locationSteps = new String[1] {
                _locationSteps[_locationSteps.Length - 1]
            };
            ai._arg = ai.GetFullPath();

            _pathTarget = pathTargetLeft;
            Array.Resize <String>(ref _locationSteps, _locationSteps.Length - 1);
            _arg = GetFullPath();
        }
Beispiel #6
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();
        }
Beispiel #7
0
        public FileSystemItem SearchResolvedPath(ArgInfo ai)
        {
            ArgInfo        aiRes = ai.Resolved;
            FileSystemItem item  = null;

            List <String> locationSteps = new List <String>();

            locationSteps.Add(aiRes.DriveForSearch);
            locationSteps.AddRange(aiRes.StepsForSearch);

            FsContainer cont = _root;

            for (Int32 i = 0; i < locationSteps.Count; ++i)
            {
                String step = locationSteps[i];
                item = cont[step];
                if (item == null && i == locationSteps.Count - 1 && aiRes.PathTarget == ArgInfo.TargetType.FileOrDir)
                {
                    step += "_d";
                    item  = cont[step];
                    if (item != null && !(item is FsDir))
                    {
                        item = null;
                    }
                }
                if (item == null)
                {
                    //throw new ApplicationException( String.Format("Can't locate path '{0}'.", aiRes.Arg) );
                    break;
                }

                if (item is FsContainer)
                {
                    cont = (FsContainer)item;
                }
                else if (item is FsLink)
                {
                    FileSystemItem itTo = GetTargetItemOfLink((FsLink)item);
                    if (itTo is FsContainer)
                    {
                        if (i != locationSteps.Count - 1)
                        {
                            item = cont = (FsContainer)itTo;
                        }
                    }
                    else if (i != locationSteps.Count - 1)
                    {
                        //throw new ApplicationException( String.Format("Can't locate path '{0}'. There isn't directory under the link '{1}'.", aiRes.Arg, itTo.ToString()) );
                        item = null;
                        break;
                    }
                }
                else if (i != locationSteps.Count - 1)
                {
                    //throw new ApplicationException( String.Format("Can't locate path '{0}'. There isn't directory.", aiRes.Arg) );
                    item = null;
                    break;
                }
            }
            if (item != null && ai.PathTarget == ArgInfo.TargetType.FileOrDir)
            {
                FileSystemItem itTest;
                if (item is FsLink)
                {
                    itTest = GetTargetItemOfLink((FsLink)item);
                }
                else
                {
                    itTest = item;
                }

                ai.PathTarget    = (item is FsDir ? ArgInfo.TargetType.Dir:ArgInfo.TargetType.File);
                aiRes.PathTarget = ai.PathTarget;
            }
            return(item);
        }
Beispiel #8
0
 protected override void Construct()
 {
     _newCurrDir            = _arguments[0];
     _newCurrDir.PathTarget = ArgInfo.TargetType.Dir;
 }
Beispiel #9
0
 protected override void Construct()
 {
     _sourceFilePath = _arguments[0];
     //_sourceFilePath.PathTarget = TargetType.File;
     //should be failed at Execute if target is a Dir
 }
Beispiel #10
0
 protected override void Construct()
 {
     _treeToRemove            = _arguments[0];
     _treeToRemove.PathTarget = ArgInfo.TargetType.Dir;
 }
Beispiel #11
0
 protected override void Construct()
 {
     _dirPath            = _arguments[0];
     _dirPath.PathTarget = ArgInfo.TargetType.Dir;
 }