示例#1
0
        internal PathInfo SetLocation(string path, ProviderRuntime providerRuntime)
        {
            // TODO: deal with paths starting with ".\"

            if (path == null)
            {
                throw new NullReferenceException("Path can't be null");
            }

            path = PathIntrinsics.NormalizePath(path);

            ProviderInfo provider  = null;
            string       driveName = null;

            string      str          = path;
            string      providerId   = null;
            PSDriveInfo currentDrive = CurrentDrive;

            // If path doesn't start with a drive name
            if (path.StartsWith(PathIntrinsics.CorrectSlash.ToString()))
            {
                provider = CurrentLocation.Provider;
            }
            else if (PathIntrinsics.IsAbsolutePath(path, out driveName))
            {
                _currentDrive = GetDrive(driveName, null);

                path = PathIntrinsics.NormalizePath(PathIntrinsics.RemoveDriveName(path));
            }

            _currentDrive.CurrentLocation = path;

            _providersCurrentDrive[CurrentDrive.Provider] = CurrentDrive;

            SetVariable("PWD", CurrentLocation);
            return(CurrentLocation);


            PSDriveInfo drive = CurrentDrive;

            SetLocation(path);
        }