} // RemoveDrive /// <summary> /// Removes the drive with the specified name. /// </summary> /// /// <param name="driveName"> /// The name of the drive to remove. /// </param> /// /// <param name="force"> /// Determines whether drive should be forcefully removed even if there was errors. /// </param> /// /// <param name="scopeID"> /// The ID of the scope from which to remove the drive. /// If the scope ID is null or empty, the scope hierarchy will be searched /// starting at the current scope through all the parent scopes to the /// global scope until a drive of the given name is found to remove. /// </param> /// /// <param name="context"> /// The context of the command. /// </param> /// internal void RemoveDrive( string driveName, bool force, string scopeID, CmdletProviderContext context) { if (driveName == null) { throw PSTraceSource.NewArgumentNullException("driveName"); } Dbg.Diagnostics.Assert( context != null, "The caller should verify the context"); PSDriveInfo drive = GetDrive(driveName, scopeID); if (drive == null) { DriveNotFoundException e = new DriveNotFoundException( driveName, "DriveNotFound", SessionStateStrings.DriveNotFound); context.WriteError(new ErrorRecord(e.ErrorRecord, e)); } else { RemoveDrive(drive, force, scopeID, context); } } // RemoveDrive
protected override void ProcessRecord() { try { CmdletProviderContext cmdletProviderContext = this.CmdletProviderContext; cmdletProviderContext.PassThru = base.PassThru; base.InvokeProvider.Property.Rename(this.path, this.Name, this.NewName, cmdletProviderContext); } catch (PSNotSupportedException pSNotSupportedException1) { PSNotSupportedException pSNotSupportedException = pSNotSupportedException1; base.WriteError(new ErrorRecord(pSNotSupportedException.ErrorRecord, pSNotSupportedException)); } catch (DriveNotFoundException driveNotFoundException1) { DriveNotFoundException driveNotFoundException = driveNotFoundException1; base.WriteError(new ErrorRecord(driveNotFoundException.ErrorRecord, driveNotFoundException)); } catch (ProviderNotFoundException providerNotFoundException1) { ProviderNotFoundException providerNotFoundException = providerNotFoundException1; base.WriteError(new ErrorRecord(providerNotFoundException.ErrorRecord, providerNotFoundException)); } catch (ItemNotFoundException itemNotFoundException1) { ItemNotFoundException itemNotFoundException = itemNotFoundException1; base.WriteError(new ErrorRecord(itemNotFoundException.ErrorRecord, itemNotFoundException)); } }
protected override void ProcessRecord() { ProviderInfo providerInfo = null; string[] path = this.Path; for (int i = 0; i < (int)path.Length; i++) { string str = path[i]; try { Collection <string> resolvedProviderPathFromPSPath = base.SessionState.Path.GetResolvedProviderPathFromPSPath(str, this.CmdletProviderContext, out providerInfo); base.WriteObject(resolvedProviderPathFromPSPath, true); } catch (PSNotSupportedException pSNotSupportedException1) { PSNotSupportedException pSNotSupportedException = pSNotSupportedException1; base.WriteError(new ErrorRecord(pSNotSupportedException.ErrorRecord, pSNotSupportedException)); } catch (DriveNotFoundException driveNotFoundException1) { DriveNotFoundException driveNotFoundException = driveNotFoundException1; base.WriteError(new ErrorRecord(driveNotFoundException.ErrorRecord, driveNotFoundException)); } catch (ProviderNotFoundException providerNotFoundException1) { ProviderNotFoundException providerNotFoundException = providerNotFoundException1; base.WriteError(new ErrorRecord(providerNotFoundException.ErrorRecord, providerNotFoundException)); } catch (ItemNotFoundException itemNotFoundException1) { ItemNotFoundException itemNotFoundException = itemNotFoundException1; base.WriteError(new ErrorRecord(itemNotFoundException.ErrorRecord, itemNotFoundException)); } } }
protected override void ProcessRecord() { string[] path = this.Path; for (int i = 0; i < (int)path.Length; i++) { string str = path[i]; try { base.InvokeProvider.Property.New(str, this.Name, this.PropertyType, this.Value, this.CmdletProviderContext); } catch (PSNotSupportedException pSNotSupportedException1) { PSNotSupportedException pSNotSupportedException = pSNotSupportedException1; base.WriteError(new ErrorRecord(pSNotSupportedException.ErrorRecord, pSNotSupportedException)); } catch (DriveNotFoundException driveNotFoundException1) { DriveNotFoundException driveNotFoundException = driveNotFoundException1; base.WriteError(new ErrorRecord(driveNotFoundException.ErrorRecord, driveNotFoundException)); } catch (ProviderNotFoundException providerNotFoundException1) { ProviderNotFoundException providerNotFoundException = providerNotFoundException1; base.WriteError(new ErrorRecord(providerNotFoundException.ErrorRecord, providerNotFoundException)); } catch (ItemNotFoundException itemNotFoundException1) { ItemNotFoundException itemNotFoundException = itemNotFoundException1; base.WriteError(new ErrorRecord(itemNotFoundException.ErrorRecord, itemNotFoundException)); } } }
protected override void ProcessRecord() { string[] strArrays = this.paths; for (int i = 0; i < (int)strArrays.Length; i++) { string str = strArrays[i]; object[] objArray = new object[1]; objArray[0] = str; CoreCommandBase.tracer.WriteLine("Invoking {0}", objArray); try { base.InvokeProvider.Item.Invoke(str, this.CmdletProviderContext); } catch (PSNotSupportedException pSNotSupportedException1) { PSNotSupportedException pSNotSupportedException = pSNotSupportedException1; base.WriteError(new ErrorRecord(pSNotSupportedException.ErrorRecord, pSNotSupportedException)); } catch (DriveNotFoundException driveNotFoundException1) { DriveNotFoundException driveNotFoundException = driveNotFoundException1; base.WriteError(new ErrorRecord(driveNotFoundException.ErrorRecord, driveNotFoundException)); } catch (ProviderNotFoundException providerNotFoundException1) { ProviderNotFoundException providerNotFoundException = providerNotFoundException1; base.WriteError(new ErrorRecord(providerNotFoundException.ErrorRecord, providerNotFoundException)); } catch (ItemNotFoundException itemNotFoundException1) { ItemNotFoundException itemNotFoundException = itemNotFoundException1; base.WriteError(new ErrorRecord(itemNotFoundException.ErrorRecord, itemNotFoundException)); } } }
protected override void ProcessRecord() { try { PathInfo pathInfo = base.SessionState.Path.PopLocation(this.stackName); if (this.PassThru) { base.WriteObject(pathInfo); } } catch (DriveNotFoundException driveNotFoundException1) { DriveNotFoundException driveNotFoundException = driveNotFoundException1; base.WriteError(new ErrorRecord(driveNotFoundException.ErrorRecord, driveNotFoundException)); } catch (ProviderNotFoundException providerNotFoundException1) { ProviderNotFoundException providerNotFoundException = providerNotFoundException1; base.WriteError(new ErrorRecord(providerNotFoundException.ErrorRecord, providerNotFoundException)); } catch (PSArgumentException pSArgumentException1) { PSArgumentException pSArgumentException = pSArgumentException1; base.WriteError(new ErrorRecord(pSArgumentException.ErrorRecord, pSArgumentException)); } catch (ItemNotFoundException itemNotFoundException1) { ItemNotFoundException itemNotFoundException = itemNotFoundException1; base.WriteError(new ErrorRecord(itemNotFoundException.ErrorRecord, itemNotFoundException)); } }
protected override void ProcessRecord() { string[] path = this.Path; for (int i = 0; i < (int)path.Length; i++) { string str = path[i]; try { base.InvokeProvider.Property.Get(str, SessionStateUtilities.ConvertArrayToCollection <string>(this.property), this.CmdletProviderContext); } catch (PSNotSupportedException pSNotSupportedException1) { PSNotSupportedException pSNotSupportedException = pSNotSupportedException1; base.WriteError(new ErrorRecord(pSNotSupportedException.ErrorRecord, pSNotSupportedException)); } catch (DriveNotFoundException driveNotFoundException1) { DriveNotFoundException driveNotFoundException = driveNotFoundException1; base.WriteError(new ErrorRecord(driveNotFoundException.ErrorRecord, driveNotFoundException)); } catch (ProviderNotFoundException providerNotFoundException1) { ProviderNotFoundException providerNotFoundException = providerNotFoundException1; base.WriteError(new ErrorRecord(providerNotFoundException.ErrorRecord, providerNotFoundException)); } catch (ItemNotFoundException itemNotFoundException1) { ItemNotFoundException itemNotFoundException = itemNotFoundException1; base.WriteError(new ErrorRecord(itemNotFoundException.ErrorRecord, itemNotFoundException)); } } }
protected override void ProcessRecord() { Collection <PathInfo> resolvedPSPathFromPSPath; string[] path = this.Path; for (int i = 0; i < (int)path.Length; i++) { string str = path[i]; resolvedPSPathFromPSPath = null; try { resolvedPSPathFromPSPath = base.SessionState.Path.GetResolvedPSPathFromPSPath(str, this.CmdletProviderContext); if (this.relative) { foreach (PathInfo pathInfo in resolvedPSPathFromPSPath) { string str1 = base.SessionState.Path.NormalizeRelativePath(pathInfo.Path, base.SessionState.Path.CurrentLocation.ProviderPath); if (!str1.StartsWith(".", StringComparison.OrdinalIgnoreCase)) { str1 = base.SessionState.Path.Combine(".", str1); } base.WriteObject(str1, false); } } goto Label0; } catch (PSNotSupportedException pSNotSupportedException1) { PSNotSupportedException pSNotSupportedException = pSNotSupportedException1; base.WriteError(new ErrorRecord(pSNotSupportedException.ErrorRecord, pSNotSupportedException)); } catch (DriveNotFoundException driveNotFoundException1) { DriveNotFoundException driveNotFoundException = driveNotFoundException1; base.WriteError(new ErrorRecord(driveNotFoundException.ErrorRecord, driveNotFoundException)); } catch (ProviderNotFoundException providerNotFoundException1) { ProviderNotFoundException providerNotFoundException = providerNotFoundException1; base.WriteError(new ErrorRecord(providerNotFoundException.ErrorRecord, providerNotFoundException)); } catch (ItemNotFoundException itemNotFoundException1) { ItemNotFoundException itemNotFoundException = itemNotFoundException1; base.WriteError(new ErrorRecord(itemNotFoundException.ErrorRecord, itemNotFoundException)); } } return; Label0: if (!this.relative) { base.WriteObject(resolvedPSPathFromPSPath, true); return; } else { return; } }
protected override void ProcessRecord() { string[] strArrays = this.paths; for (int i = 0; i < (int)strArrays.Length; i++) { string str = strArrays[i]; try { base.InvokeProvider.Item.Get(str, this.CmdletProviderContext); } catch (PSNotSupportedException pSNotSupportedException1) { PSNotSupportedException pSNotSupportedException = pSNotSupportedException1; base.WriteError(new ErrorRecord(pSNotSupportedException.ErrorRecord, pSNotSupportedException)); } catch (DriveNotFoundException driveNotFoundException1) { DriveNotFoundException driveNotFoundException = driveNotFoundException1; base.WriteError(new ErrorRecord(driveNotFoundException.ErrorRecord, driveNotFoundException)); } catch (ProviderNotFoundException providerNotFoundException1) { ProviderNotFoundException providerNotFoundException = providerNotFoundException1; base.WriteError(new ErrorRecord(providerNotFoundException.ErrorRecord, providerNotFoundException)); } catch (ItemNotFoundException itemNotFoundException1) { ItemNotFoundException itemNotFoundException = itemNotFoundException1; base.WriteError(new ErrorRecord(itemNotFoundException.ErrorRecord, itemNotFoundException)); } } }
private Collection <PathInfo> GetResolvedPaths(string path) { Collection <PathInfo> pathInfos = new Collection <PathInfo>(); try { pathInfos = base.SessionState.Path.GetResolvedPSPathFromPSPath(path); } catch (PSNotSupportedException pSNotSupportedException1) { PSNotSupportedException pSNotSupportedException = pSNotSupportedException1; base.WriteError(new ErrorRecord(pSNotSupportedException.ErrorRecord, pSNotSupportedException)); } catch (DriveNotFoundException driveNotFoundException1) { DriveNotFoundException driveNotFoundException = driveNotFoundException1; base.WriteError(new ErrorRecord(driveNotFoundException.ErrorRecord, driveNotFoundException)); } catch (ProviderNotFoundException providerNotFoundException1) { ProviderNotFoundException providerNotFoundException = providerNotFoundException1; base.WriteError(new ErrorRecord(providerNotFoundException.ErrorRecord, providerNotFoundException)); } catch (ItemNotFoundException itemNotFoundException1) { ItemNotFoundException itemNotFoundException = itemNotFoundException1; base.WriteError(new ErrorRecord(itemNotFoundException.ErrorRecord, itemNotFoundException)); } return(pathInfos); }
private void DiskNotFoundMessage(DriveNotFoundException e) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Диск не найден"); Console.WriteLine(e.Message); Console.ResetColor(); }
protected override void ProcessRecord() { string[] path = this.Path; for (int i = 0; i < (int)path.Length; i++) { string str = path[i]; try { base.InvokeProvider.Property.Copy(str, this.property, this.Destination, this.property, base.GetCurrentContext()); } catch (PSNotSupportedException pSNotSupportedException1) { PSNotSupportedException pSNotSupportedException = pSNotSupportedException1; base.WriteError(new ErrorRecord(pSNotSupportedException.ErrorRecord, pSNotSupportedException)); } catch (DriveNotFoundException driveNotFoundException1) { DriveNotFoundException driveNotFoundException = driveNotFoundException1; base.WriteError(new ErrorRecord(driveNotFoundException.ErrorRecord, driveNotFoundException)); } catch (ProviderNotFoundException providerNotFoundException1) { ProviderNotFoundException providerNotFoundException = providerNotFoundException1; base.WriteError(new ErrorRecord(providerNotFoundException.ErrorRecord, providerNotFoundException)); } catch (ItemNotFoundException itemNotFoundException1) { ItemNotFoundException itemNotFoundException = itemNotFoundException1; base.WriteError(new ErrorRecord(itemNotFoundException.ErrorRecord, itemNotFoundException)); } } }
protected override void ProcessRecord() { CmdletProviderContext cmdletProviderContext = this.CmdletProviderContext; cmdletProviderContext.PassThru = false; string[] path = base.Path; for (int i = 0; i < (int)path.Length; i++) { string str = path[i]; try { base.InvokeProvider.Content.Clear(str, cmdletProviderContext); } catch (PSNotSupportedException pSNotSupportedException1) { PSNotSupportedException pSNotSupportedException = pSNotSupportedException1; base.WriteError(new ErrorRecord(pSNotSupportedException.ErrorRecord, pSNotSupportedException)); } catch (DriveNotFoundException driveNotFoundException1) { DriveNotFoundException driveNotFoundException = driveNotFoundException1; base.WriteError(new ErrorRecord(driveNotFoundException.ErrorRecord, driveNotFoundException)); } catch (ProviderNotFoundException providerNotFoundException1) { ProviderNotFoundException providerNotFoundException = providerNotFoundException1; base.WriteError(new ErrorRecord(providerNotFoundException.ErrorRecord, providerNotFoundException)); } catch (ItemNotFoundException itemNotFoundException1) { ItemNotFoundException itemNotFoundException = itemNotFoundException1; base.WriteError(new ErrorRecord(itemNotFoundException.ErrorRecord, itemNotFoundException)); } } }
protected override void ProcessRecord() { string removeDriveConfirmAction = NavigationResources.RemoveDriveConfirmAction; string removeDriveConfirmResourceTemplate = NavigationResources.RemoveDriveConfirmResourceTemplate; bool flag = true; if (this.names == null) { string[] empty = new string[1]; empty[0] = string.Empty; this.names = empty; flag = false; } string[] strArrays = this.names; for (int i = 0; i < (int)strArrays.Length; i++) { string str = strArrays[i]; bool flag1 = false; try { foreach (PSDriveInfo matchingDrife in base.GetMatchingDrives(str, this.PSProvider, this.Scope)) { object[] name = new object[3]; name[0] = matchingDrife.Name; name[1] = matchingDrife.Provider; name[2] = matchingDrife.Root; string str1 = string.Format(Thread.CurrentThread.CurrentCulture, removeDriveConfirmResourceTemplate, name); flag1 = true; if (!base.ShouldProcess(str1, removeDriveConfirmAction)) { continue; } if (this.Force || !(matchingDrife == base.SessionState.Drive.Current)) { base.SessionState.Drive.Remove(matchingDrife.Name, this.Force, this.Scope, this.CmdletProviderContext); } else { object[] objArray = new object[1]; objArray[0] = matchingDrife.Name; PSInvalidOperationException pSInvalidOperationException = PSTraceSource.NewInvalidOperationException("NavigationResources", "RemoveDriveInUse", objArray); base.WriteError(new ErrorRecord(pSInvalidOperationException.ErrorRecord, pSInvalidOperationException)); } } } catch (DriveNotFoundException driveNotFoundException) { } catch (ProviderNotFoundException providerNotFoundException) { } if (flag && !flag1) { DriveNotFoundException driveNotFoundException1 = new DriveNotFoundException(str, "DriveNotFound", SessionStateStrings.DriveNotFound); base.WriteError(new ErrorRecord(driveNotFoundException1.ErrorRecord, driveNotFoundException1)); } } }
protected override void ProcessRecord() { CmdletProviderContext cmdletProviderContext = this.CmdletProviderContext; cmdletProviderContext.PassThru = base.PassThru; PSObject pSObject = null; string parameterSetName = base.ParameterSetName; string str = parameterSetName; if (parameterSetName != null) { if (str == "propertyValuePathSet" || str == "propertyValueLiteralPathSet") { pSObject = new PSObject(); pSObject.Properties.Add(new PSNoteProperty(this.Name, this.Value)); } else { if (str == "propertyPSObjectPathSet") { pSObject = this.InputObject; } } } string[] path = this.Path; for (int i = 0; i < (int)path.Length; i++) { string str1 = path[i]; try { base.InvokeProvider.Property.Set(str1, pSObject, cmdletProviderContext); } catch (PSNotSupportedException pSNotSupportedException1) { PSNotSupportedException pSNotSupportedException = pSNotSupportedException1; base.WriteError(new ErrorRecord(pSNotSupportedException.ErrorRecord, pSNotSupportedException)); } catch (DriveNotFoundException driveNotFoundException1) { DriveNotFoundException driveNotFoundException = driveNotFoundException1; base.WriteError(new ErrorRecord(driveNotFoundException.ErrorRecord, driveNotFoundException)); } catch (ProviderNotFoundException providerNotFoundException1) { ProviderNotFoundException providerNotFoundException = providerNotFoundException1; base.WriteError(new ErrorRecord(providerNotFoundException.ErrorRecord, providerNotFoundException)); } catch (ItemNotFoundException itemNotFoundException1) { ItemNotFoundException itemNotFoundException = itemNotFoundException1; base.WriteError(new ErrorRecord(itemNotFoundException.ErrorRecord, itemNotFoundException)); } } }
protected override void ProcessRecord() { CmdletProviderContext cmdletProviderContext = this.CmdletProviderContext; if (this.paths == null || this.paths != null && (int)this.paths.Length == 0) { string[] empty = new string[1]; empty[0] = string.Empty; this.paths = empty; } string[] strArrays = this.paths; for (int i = 0; i < (int)strArrays.Length; i++) { string str = strArrays[i]; string parameterSetName = base.ParameterSetName; string str1 = parameterSetName; if (parameterSetName != null && (str1 == "Items" || str1 == "LiteralItems")) { try { if (!this.Name) { base.InvokeProvider.ChildItem.Get(str, this.Recurse, cmdletProviderContext); } else { base.InvokeProvider.ChildItem.GetNames(str, ReturnContainers.ReturnMatchingContainers, this.Recurse, cmdletProviderContext); } } catch (PSNotSupportedException pSNotSupportedException1) { PSNotSupportedException pSNotSupportedException = pSNotSupportedException1; base.WriteError(new ErrorRecord(pSNotSupportedException.ErrorRecord, pSNotSupportedException)); } catch (DriveNotFoundException driveNotFoundException1) { DriveNotFoundException driveNotFoundException = driveNotFoundException1; base.WriteError(new ErrorRecord(driveNotFoundException.ErrorRecord, driveNotFoundException)); } catch (ProviderNotFoundException providerNotFoundException1) { ProviderNotFoundException providerNotFoundException = providerNotFoundException1; base.WriteError(new ErrorRecord(providerNotFoundException.ErrorRecord, providerNotFoundException)); } catch (ItemNotFoundException itemNotFoundException1) { ItemNotFoundException itemNotFoundException = itemNotFoundException1; base.WriteError(new ErrorRecord(itemNotFoundException.ErrorRecord, itemNotFoundException)); } } } }
internal List <ContentCommandBase.ContentHolder> GetContentReaders(string[] readerPaths, CmdletProviderContext currentCommandContext) { Collection <PathInfo> pathInfos = this.ResolvePaths(readerPaths, false, true, currentCommandContext); List <ContentCommandBase.ContentHolder> contentHolders = new List <ContentCommandBase.ContentHolder>(); foreach (PathInfo pathInfo in pathInfos) { Collection <IContentReader> reader = null; try { string path = WildcardPattern.Escape(pathInfo.Path); if (currentCommandContext.SuppressWildcardExpansion) { path = pathInfo.Path; } reader = base.InvokeProvider.Content.GetReader(path, currentCommandContext); } catch (PSNotSupportedException pSNotSupportedException1) { PSNotSupportedException pSNotSupportedException = pSNotSupportedException1; base.WriteError(new ErrorRecord(pSNotSupportedException.ErrorRecord, pSNotSupportedException)); continue; } catch (DriveNotFoundException driveNotFoundException1) { DriveNotFoundException driveNotFoundException = driveNotFoundException1; base.WriteError(new ErrorRecord(driveNotFoundException.ErrorRecord, driveNotFoundException)); continue; } catch (ProviderNotFoundException providerNotFoundException1) { ProviderNotFoundException providerNotFoundException = providerNotFoundException1; base.WriteError(new ErrorRecord(providerNotFoundException.ErrorRecord, providerNotFoundException)); continue; } catch (ItemNotFoundException itemNotFoundException1) { ItemNotFoundException itemNotFoundException = itemNotFoundException1; base.WriteError(new ErrorRecord(itemNotFoundException.ErrorRecord, itemNotFoundException)); continue; } if (reader == null || reader.Count <= 0 || reader.Count != 1 || reader[0] == null) { continue; } ContentCommandBase.ContentHolder contentHolder = new ContentCommandBase.ContentHolder(pathInfo, reader[0], null); contentHolders.Add(contentHolder); } return(contentHolders); }
protected override void ProcessRecord() { CopyContainers copyContainer; CmdletProviderContext cmdletProviderContext = this.CmdletProviderContext; cmdletProviderContext.PassThru = this.PassThru; string[] strArrays = this.paths; for (int i = 0; i < (int)strArrays.Length; i++) { string str = strArrays[i]; object[] destination = new object[2]; destination[0] = str; destination[1] = this.Destination; CoreCommandBase.tracer.WriteLine("Copy {0} to {1}", destination); try { if (this.Container) { copyContainer = CopyContainers.CopyTargetContainer; } else { copyContainer = CopyContainers.CopyChildrenOfTargetContainer; } CopyContainers copyContainer1 = copyContainer; base.InvokeProvider.Item.Copy(str, this.Destination, this.Recurse, copyContainer1, cmdletProviderContext); } catch (PSNotSupportedException pSNotSupportedException1) { PSNotSupportedException pSNotSupportedException = pSNotSupportedException1; base.WriteError(new ErrorRecord(pSNotSupportedException.ErrorRecord, pSNotSupportedException)); } catch (DriveNotFoundException driveNotFoundException1) { DriveNotFoundException driveNotFoundException = driveNotFoundException1; base.WriteError(new ErrorRecord(driveNotFoundException.ErrorRecord, driveNotFoundException)); } catch (ProviderNotFoundException providerNotFoundException1) { ProviderNotFoundException providerNotFoundException = providerNotFoundException1; base.WriteError(new ErrorRecord(providerNotFoundException.ErrorRecord, providerNotFoundException)); } catch (ItemNotFoundException itemNotFoundException1) { ItemNotFoundException itemNotFoundException = itemNotFoundException1; base.WriteError(new ErrorRecord(itemNotFoundException.ErrorRecord, itemNotFoundException)); } } }
protected override void ProcessRecord() { string[] name = this.Name; for (int i = 0; i < (int)name.Length; i++) { string str = name[i]; try { List <PSDriveInfo> matchingDrives = base.GetMatchingDrives(str, this.PSProvider, this.Scope); if (matchingDrives.Count <= 0) { if (!WildcardPattern.ContainsWildcardCharacters(str)) { DriveNotFoundException driveNotFoundException = new DriveNotFoundException(str, "DriveNotFound", SessionStateStrings.DriveNotFound); base.WriteError(new ErrorRecord(driveNotFoundException, "GetDriveNoMatchingDrive", ErrorCategory.ObjectNotFound, str)); } } else { base.WriteObject(matchingDrives, true); } } catch (DriveNotFoundException driveNotFoundException2) { DriveNotFoundException driveNotFoundException1 = driveNotFoundException2; ErrorRecord errorRecord = new ErrorRecord(driveNotFoundException1, "GetLocationNoMatchingDrive", ErrorCategory.ObjectNotFound, str); base.WriteError(errorRecord); } catch (ProviderNotFoundException providerNotFoundException1) { ProviderNotFoundException providerNotFoundException = providerNotFoundException1; ErrorRecord errorRecord1 = new ErrorRecord(providerNotFoundException, "GetLocationNoMatchingDrive", ErrorCategory.ObjectNotFound, this.PSProvider); base.WriteError(errorRecord1); } catch (PSArgumentOutOfRangeException pSArgumentOutOfRangeException1) { PSArgumentOutOfRangeException pSArgumentOutOfRangeException = pSArgumentOutOfRangeException1; base.WriteError(new ErrorRecord(pSArgumentOutOfRangeException.ErrorRecord, pSArgumentOutOfRangeException)); } catch (PSArgumentException pSArgumentException1) { PSArgumentException pSArgumentException = pSArgumentException1; base.WriteError(new ErrorRecord(pSArgumentException.ErrorRecord, pSArgumentException)); } } }
internal List <ContentCommandBase.ContentHolder> GetContentWriters(string[] writerPaths, CmdletProviderContext currentCommandContext) { Collection <PathInfo> pathInfos = base.ResolvePaths(writerPaths, true, false, currentCommandContext); List <ContentCommandBase.ContentHolder> contentHolders = new List <ContentCommandBase.ContentHolder>(); foreach (PathInfo pathInfo in pathInfos) { Collection <IContentWriter> writer = null; try { writer = base.InvokeProvider.Content.GetWriter(pathInfo.Path, currentCommandContext); } catch (PSNotSupportedException pSNotSupportedException1) { PSNotSupportedException pSNotSupportedException = pSNotSupportedException1; base.WriteError(new ErrorRecord(pSNotSupportedException.ErrorRecord, pSNotSupportedException)); continue; } catch (DriveNotFoundException driveNotFoundException1) { DriveNotFoundException driveNotFoundException = driveNotFoundException1; base.WriteError(new ErrorRecord(driveNotFoundException.ErrorRecord, driveNotFoundException)); continue; } catch (ProviderNotFoundException providerNotFoundException1) { ProviderNotFoundException providerNotFoundException = providerNotFoundException1; base.WriteError(new ErrorRecord(providerNotFoundException.ErrorRecord, providerNotFoundException)); continue; } catch (ItemNotFoundException itemNotFoundException1) { ItemNotFoundException itemNotFoundException = itemNotFoundException1; base.WriteError(new ErrorRecord(itemNotFoundException.ErrorRecord, itemNotFoundException)); continue; } if (writer == null || writer.Count <= 0 || writer.Count != 1 || writer[0] == null) { continue; } ContentCommandBase.ContentHolder contentHolder = new ContentCommandBase.ContentHolder(pathInfo, null, writer[0]); contentHolders.Add(contentHolder); } return(contentHolders); }
internal override void BeforeOpenStreams(string[] paths) { if (paths == null || paths != null && (int)paths.Length == 0) { throw PSTraceSource.NewArgumentNullException("paths"); } else { CmdletProviderContext cmdletProviderContext = new CmdletProviderContext(base.GetCurrentContext()); string[] strArrays = paths; for (int i = 0; i < (int)strArrays.Length; i++) { string str = strArrays[i]; try { base.InvokeProvider.Content.Clear(str, cmdletProviderContext); cmdletProviderContext.ThrowFirstErrorOrDoNothing(true); } catch (PSNotSupportedException pSNotSupportedException) { } catch (DriveNotFoundException driveNotFoundException1) { DriveNotFoundException driveNotFoundException = driveNotFoundException1; base.WriteError(new ErrorRecord(driveNotFoundException.ErrorRecord, driveNotFoundException)); } catch (ProviderNotFoundException providerNotFoundException1) { ProviderNotFoundException providerNotFoundException = providerNotFoundException1; base.WriteError(new ErrorRecord(providerNotFoundException.ErrorRecord, providerNotFoundException)); } catch (ItemNotFoundException itemNotFoundException) { } } return; } }
protected override void ProcessRecord() { if (this.paths == null || this.paths != null && (int)this.paths.Length == 0) { string[] empty = new string[1]; empty[0] = string.Empty; this.paths = empty; } string[] strArrays = this.paths; for (int i = 0; i < (int)strArrays.Length; i++) { string str = strArrays[i]; try { base.InvokeProvider.Item.New(str, this.Name, this.ItemType, this.Value, this.CmdletProviderContext); } catch (PSNotSupportedException pSNotSupportedException1) { PSNotSupportedException pSNotSupportedException = pSNotSupportedException1; base.WriteError(new ErrorRecord(pSNotSupportedException.ErrorRecord, pSNotSupportedException)); } catch (DriveNotFoundException driveNotFoundException1) { DriveNotFoundException driveNotFoundException = driveNotFoundException1; base.WriteError(new ErrorRecord(driveNotFoundException.ErrorRecord, driveNotFoundException)); } catch (ProviderNotFoundException providerNotFoundException1) { ProviderNotFoundException providerNotFoundException = providerNotFoundException1; base.WriteError(new ErrorRecord(providerNotFoundException.ErrorRecord, providerNotFoundException)); } catch (ItemNotFoundException itemNotFoundException1) { ItemNotFoundException itemNotFoundException = itemNotFoundException1; base.WriteError(new ErrorRecord(itemNotFoundException.ErrorRecord, itemNotFoundException)); } } }
internal static Exception GetWindowsErrorException(int errorCode, string parameterName) { string message = new Win32Exception(errorCode).Message; Exception retval; if (ERROR_FILE_NOT_FOUND == errorCode) { retval = new FileNotFoundException(message); } else if (ERROR_INVALID_DRIVE == errorCode) { retval = new DriveNotFoundException(message); } else if (ERROR_ACCESS_DENIED == errorCode) { retval = new UnauthorizedAccessException(message); } else if (ERROR_PATH_NOT_FOUND == errorCode) { retval = new DirectoryNotFoundException(message); } else if (ERROR_FILE_NAME_TOO_LONG == errorCode) { retval = new PathTooLongException(message); } else if (ERROR_INVALID_NAME == errorCode) { retval = new ArgumentException(message, parameterName); } else { retval = new IOException(message, ErrorCodeToHResult(errorCode)); } return(retval); }
protected override void ProcessRecord() { CmdletProviderContext cmdletProviderContext; Collection <PathInfo> resolvedPSPathFromPSPath; StringCollection stringCollections = new StringCollection(); if (!this.resolve) { stringCollections.AddRange(this.Path); } else { cmdletProviderContext = this.CmdletProviderContext; string[] strArrays = this.paths; for (int i = 0; i < (int)strArrays.Length; i++) { string str = strArrays[i]; resolvedPSPathFromPSPath = null; try { resolvedPSPathFromPSPath = base.SessionState.Path.GetResolvedPSPathFromPSPath(str, cmdletProviderContext); goto Label0; } catch (PSNotSupportedException pSNotSupportedException1) { PSNotSupportedException pSNotSupportedException = pSNotSupportedException1; base.WriteError(new ErrorRecord(pSNotSupportedException.ErrorRecord, pSNotSupportedException)); } catch (DriveNotFoundException driveNotFoundException1) { DriveNotFoundException driveNotFoundException = driveNotFoundException1; base.WriteError(new ErrorRecord(driveNotFoundException.ErrorRecord, driveNotFoundException)); } catch (ProviderNotFoundException providerNotFoundException1) { ProviderNotFoundException providerNotFoundException = providerNotFoundException1; base.WriteError(new ErrorRecord(providerNotFoundException.ErrorRecord, providerNotFoundException)); } catch (ItemNotFoundException itemNotFoundException1) { ItemNotFoundException itemNotFoundException = itemNotFoundException1; base.WriteError(new ErrorRecord(itemNotFoundException.ErrorRecord, itemNotFoundException)); } } } Label3: int num = 0; while (num < stringCollections.Count) { string empty = null; string parameterSetName = base.ParameterSetName; string str1 = parameterSetName; if (parameterSetName != null) { if (str1 == "IsAbsoluteSet") { string str2 = null; bool flag = base.SessionState.Path.IsPSAbsolute(stringCollections[num], out str2); base.WriteObject(flag); goto Label1; } else if (str1 == "QualifierSet") { int num1 = stringCollections[num].IndexOf(":", StringComparison.CurrentCulture); if (num1 >= 0) { if (!base.SessionState.Path.IsProviderQualified(stringCollections[num])) { empty = stringCollections[num].Substring(0, num1 + 1); goto Label2; } else { empty = stringCollections[num].Substring(0, num1 + 2); goto Label2; } } else { FormatException formatException = new FormatException(StringUtil.Format(NavigationResources.ParsePathFormatError, stringCollections[num])); base.WriteError(new ErrorRecord(formatException, "ParsePathFormatError", ErrorCategory.InvalidArgument, stringCollections[num])); goto Label1; } } else if (str1 == "ParentSet" || str1 == "LiteralPathSet") { if (!stringCollections[num].StartsWith("\\", StringComparison.CurrentCulture)) { stringCollections[num].StartsWith("/", StringComparison.CurrentCulture); } try { empty = base.SessionState.Path.ParseParent(stringCollections[num], string.Empty, this.CmdletProviderContext, true); goto Label2; } catch (PSNotSupportedException pSNotSupportedException2) { empty = string.Empty; goto Label2; } } else if (str1 == "LeafSet") { try { empty = base.SessionState.Path.ParseChildName(stringCollections[num], this.CmdletProviderContext, true); goto Label2; } catch (PSNotSupportedException pSNotSupportedException3) { empty = stringCollections[num]; goto Label2; } catch (DriveNotFoundException driveNotFoundException3) { DriveNotFoundException driveNotFoundException2 = driveNotFoundException3; base.WriteError(new ErrorRecord(driveNotFoundException2.ErrorRecord, driveNotFoundException2)); goto Label1; } catch (ProviderNotFoundException providerNotFoundException3) { ProviderNotFoundException providerNotFoundException2 = providerNotFoundException3; base.WriteError(new ErrorRecord(providerNotFoundException2.ErrorRecord, providerNotFoundException2)); goto Label1; } } else if (str1 == "NoQualifierSet") { empty = this.RemoveQualifier(stringCollections[num]); goto Label2; } } Label2: if (empty != null) { base.WriteObject(empty); } Label1: num++; } return; Label0: IEnumerator <PathInfo> enumerator = resolvedPSPathFromPSPath.GetEnumerator(); using (enumerator) { while (enumerator.MoveNext()) { PathInfo current = enumerator.Current; try { if (base.InvokeProvider.Item.Exists(current.Path, cmdletProviderContext)) { stringCollections.Add(current.Path); } } catch (PSNotSupportedException pSNotSupportedException5) { PSNotSupportedException pSNotSupportedException4 = pSNotSupportedException5; base.WriteError(new ErrorRecord(pSNotSupportedException4.ErrorRecord, pSNotSupportedException4)); } catch (DriveNotFoundException driveNotFoundException5) { DriveNotFoundException driveNotFoundException4 = driveNotFoundException5; base.WriteError(new ErrorRecord(driveNotFoundException4.ErrorRecord, driveNotFoundException4)); } catch (ProviderNotFoundException providerNotFoundException5) { ProviderNotFoundException providerNotFoundException4 = providerNotFoundException5; base.WriteError(new ErrorRecord(providerNotFoundException4.ErrorRecord, providerNotFoundException4)); } catch (ItemNotFoundException itemNotFoundException3) { ItemNotFoundException itemNotFoundException2 = itemNotFoundException3; base.WriteError(new ErrorRecord(itemNotFoundException2.ErrorRecord, itemNotFoundException2)); } } goto Label3; } }
protected override void ProcessRecord() { CmdletProviderContext cmdletProviderContext = this.CmdletProviderContext; try { if (!base.InvokeProvider.Item.Exists(this.Path, cmdletProviderContext)) { object[] path = new object[1]; path[0] = this.Path; PSInvalidOperationException pSInvalidOperationException = PSTraceSource.NewInvalidOperationException("NavigationResources", "RenameItemDoesntExist", path); base.WriteError(new ErrorRecord(pSInvalidOperationException.ErrorRecord, pSInvalidOperationException)); return; } } catch (PSNotSupportedException pSNotSupportedException1) { PSNotSupportedException pSNotSupportedException = pSNotSupportedException1; base.WriteError(new ErrorRecord(pSNotSupportedException.ErrorRecord, pSNotSupportedException)); return; } catch (DriveNotFoundException driveNotFoundException1) { DriveNotFoundException driveNotFoundException = driveNotFoundException1; base.WriteError(new ErrorRecord(driveNotFoundException.ErrorRecord, driveNotFoundException)); return; } catch (ProviderNotFoundException providerNotFoundException1) { ProviderNotFoundException providerNotFoundException = providerNotFoundException1; base.WriteError(new ErrorRecord(providerNotFoundException.ErrorRecord, providerNotFoundException)); return; } catch (ItemNotFoundException itemNotFoundException1) { ItemNotFoundException itemNotFoundException = itemNotFoundException1; base.WriteError(new ErrorRecord(itemNotFoundException.ErrorRecord, itemNotFoundException)); return; } bool flag = false; try { flag = base.SessionState.Path.IsCurrentLocationOrAncestor(this.path, cmdletProviderContext); } catch (PSNotSupportedException pSNotSupportedException3) { PSNotSupportedException pSNotSupportedException2 = pSNotSupportedException3; base.WriteError(new ErrorRecord(pSNotSupportedException2.ErrorRecord, pSNotSupportedException2)); return; } catch (DriveNotFoundException driveNotFoundException3) { DriveNotFoundException driveNotFoundException2 = driveNotFoundException3; base.WriteError(new ErrorRecord(driveNotFoundException2.ErrorRecord, driveNotFoundException2)); return; } catch (ProviderNotFoundException providerNotFoundException3) { ProviderNotFoundException providerNotFoundException2 = providerNotFoundException3; base.WriteError(new ErrorRecord(providerNotFoundException2.ErrorRecord, providerNotFoundException2)); return; } catch (ItemNotFoundException itemNotFoundException3) { ItemNotFoundException itemNotFoundException2 = itemNotFoundException3; base.WriteError(new ErrorRecord(itemNotFoundException2.ErrorRecord, itemNotFoundException2)); return; } if (!flag) { cmdletProviderContext.PassThru = this.PassThru; object[] newName = new object[2]; newName[0] = this.Path; newName[1] = this.NewName; CoreCommandBase.tracer.WriteLine("Rename {0} to {1}", newName); try { base.InvokeProvider.Item.Rename(this.Path, this.NewName, cmdletProviderContext); } catch (PSNotSupportedException pSNotSupportedException5) { PSNotSupportedException pSNotSupportedException4 = pSNotSupportedException5; base.WriteError(new ErrorRecord(pSNotSupportedException4.ErrorRecord, pSNotSupportedException4)); return; } catch (DriveNotFoundException driveNotFoundException5) { DriveNotFoundException driveNotFoundException4 = driveNotFoundException5; base.WriteError(new ErrorRecord(driveNotFoundException4.ErrorRecord, driveNotFoundException4)); return; } catch (ProviderNotFoundException providerNotFoundException5) { ProviderNotFoundException providerNotFoundException4 = providerNotFoundException5; base.WriteError(new ErrorRecord(providerNotFoundException4.ErrorRecord, providerNotFoundException4)); return; } catch (ItemNotFoundException itemNotFoundException5) { ItemNotFoundException itemNotFoundException4 = itemNotFoundException5; base.WriteError(new ErrorRecord(itemNotFoundException4.ErrorRecord, itemNotFoundException4)); return; } return; } else { object[] objArray = new object[1]; objArray[0] = this.Path; PSInvalidOperationException pSInvalidOperationException1 = PSTraceSource.NewInvalidOperationException("NavigationResources", "RenamedItemInUse", objArray); base.WriteError(new ErrorRecord(pSInvalidOperationException1.ErrorRecord, pSInvalidOperationException1)); } }
protected override void ProcessRecord() { PathInfo pathInfo; List <PSDriveInfo> matchingDrives; string parameterSetName = base.ParameterSetName; string str = parameterSetName; if (parameterSetName != null) { if (str == "Location") { pathInfo = null; if (this.PSDrive == null || (int)this.PSDrive.Length <= 0) { if ((this.PSDrive == null || (int)this.PSDrive.Length == 0) && this.PSProvider != null && (int)this.PSProvider.Length > 0) { string[] pSProvider = this.PSProvider; for (int i = 0; i < (int)pSProvider.Length; i++) { string str1 = pSProvider[i]; bool flag = WildcardPattern.ContainsWildcardCharacters(str1); if (!flag) { try { base.SessionState.Provider.GetOne(str1); } catch (ProviderNotFoundException providerNotFoundException1) { ProviderNotFoundException providerNotFoundException = providerNotFoundException1; ErrorRecord errorRecord = new ErrorRecord(providerNotFoundException, "GetLocationNoMatchingProvider", ErrorCategory.ObjectNotFound, str1); base.WriteError(errorRecord); goto Label0; } } foreach (ProviderInfo all in base.SessionState.Provider.GetAll()) { if (!all.IsMatch(str1)) { continue; } try { base.WriteObject(base.SessionState.Path.CurrentProviderLocation(all.FullName)); } catch (ProviderNotFoundException providerNotFoundException3) { ProviderNotFoundException providerNotFoundException2 = providerNotFoundException3; base.WriteError(new ErrorRecord(providerNotFoundException2.ErrorRecord, providerNotFoundException2)); } catch (DriveNotFoundException driveNotFoundException1) { DriveNotFoundException driveNotFoundException = driveNotFoundException1; if (!flag) { base.WriteError(new ErrorRecord(driveNotFoundException.ErrorRecord, driveNotFoundException)); } } } Label0: continue; } return; } else { base.WriteObject(base.SessionState.Path.CurrentLocation); return; } } else { string[] pSDrive = this.PSDrive; for (int j = 0; j < (int)pSDrive.Length; j++) { string str2 = pSDrive[j]; matchingDrives = null; try { matchingDrives = base.GetMatchingDrives(str2, this.PSProvider, null); goto Label1; } catch (DriveNotFoundException driveNotFoundException3) { DriveNotFoundException driveNotFoundException2 = driveNotFoundException3; ErrorRecord errorRecord1 = new ErrorRecord(driveNotFoundException2, "GetLocationNoMatchingDrive", ErrorCategory.ObjectNotFound, str2); base.WriteError(errorRecord1); } catch (ProviderNotFoundException providerNotFoundException5) { ProviderNotFoundException providerNotFoundException4 = providerNotFoundException5; ErrorRecord errorRecord2 = new ErrorRecord(providerNotFoundException4, "GetLocationNoMatchingProvider", ErrorCategory.ObjectNotFound, this.PSProvider); base.WriteError(errorRecord2); } catch (ArgumentException argumentException1) { ArgumentException argumentException = argumentException1; ErrorRecord errorRecord3 = new ErrorRecord(argumentException, "GetLocationNoMatchingDrive", ErrorCategory.ObjectNotFound, str2); base.WriteError(errorRecord3); } } return; } } else { if (str == "Stack") { if (this.stackNames == null) { try { base.WriteObject(base.SessionState.Path.LocationStack(null), false); } catch (PSArgumentException pSArgumentException1) { PSArgumentException pSArgumentException = pSArgumentException1; base.WriteError(new ErrorRecord(pSArgumentException.ErrorRecord, pSArgumentException)); } } else { string[] strArrays = this.stackNames; for (int k = 0; k < (int)strArrays.Length; k++) { string str3 = strArrays[k]; try { base.WriteObject(base.SessionState.Path.LocationStack(str3), false); } catch (PSArgumentException pSArgumentException3) { PSArgumentException pSArgumentException2 = pSArgumentException3; base.WriteError(new ErrorRecord(pSArgumentException2.ErrorRecord, pSArgumentException2)); } } return; } } else { return; } } } return; Label1: List <PSDriveInfo> .Enumerator enumerator = matchingDrives.GetEnumerator(); try { while (enumerator.MoveNext()) { PSDriveInfo current = enumerator.Current; try { string driveQualifiedPath = LocationGlobber.GetDriveQualifiedPath(current.CurrentLocation, current); pathInfo = new PathInfo(current, current.Provider, driveQualifiedPath, base.SessionState); base.WriteObject(pathInfo); } catch (ProviderNotFoundException providerNotFoundException7) { ProviderNotFoundException providerNotFoundException6 = providerNotFoundException7; base.WriteError(new ErrorRecord(providerNotFoundException6.ErrorRecord, providerNotFoundException6)); } } return; } finally { enumerator.Dispose(); } }
private void MoveItem(string path) { CmdletProviderContext cmdletProviderContext = this.CmdletProviderContext; try { string str = path; if (!base.SuppressWildcardExpansion) { str = WildcardPattern.Escape(path); } if (!base.InvokeProvider.Item.Exists(str, cmdletProviderContext)) { object[] objArray = new object[1]; objArray[0] = path; PSInvalidOperationException pSInvalidOperationException = PSTraceSource.NewInvalidOperationException("NavigationResources", "MoveItemDoesntExist", objArray); base.WriteError(new ErrorRecord(pSInvalidOperationException.ErrorRecord, pSInvalidOperationException)); return; } } catch (PSNotSupportedException pSNotSupportedException1) { PSNotSupportedException pSNotSupportedException = pSNotSupportedException1; base.WriteError(new ErrorRecord(pSNotSupportedException.ErrorRecord, pSNotSupportedException)); return; } catch (DriveNotFoundException driveNotFoundException1) { DriveNotFoundException driveNotFoundException = driveNotFoundException1; base.WriteError(new ErrorRecord(driveNotFoundException.ErrorRecord, driveNotFoundException)); return; } catch (ProviderNotFoundException providerNotFoundException1) { ProviderNotFoundException providerNotFoundException = providerNotFoundException1; base.WriteError(new ErrorRecord(providerNotFoundException.ErrorRecord, providerNotFoundException)); return; } catch (ItemNotFoundException itemNotFoundException1) { ItemNotFoundException itemNotFoundException = itemNotFoundException1; base.WriteError(new ErrorRecord(itemNotFoundException.ErrorRecord, itemNotFoundException)); return; } bool flag = false; try { flag = base.SessionState.Path.IsCurrentLocationOrAncestor(path, cmdletProviderContext); } catch (PSNotSupportedException pSNotSupportedException3) { PSNotSupportedException pSNotSupportedException2 = pSNotSupportedException3; base.WriteError(new ErrorRecord(pSNotSupportedException2.ErrorRecord, pSNotSupportedException2)); return; } catch (DriveNotFoundException driveNotFoundException3) { DriveNotFoundException driveNotFoundException2 = driveNotFoundException3; base.WriteError(new ErrorRecord(driveNotFoundException2.ErrorRecord, driveNotFoundException2)); return; } catch (ProviderNotFoundException providerNotFoundException3) { ProviderNotFoundException providerNotFoundException2 = providerNotFoundException3; base.WriteError(new ErrorRecord(providerNotFoundException2.ErrorRecord, providerNotFoundException2)); return; } catch (ItemNotFoundException itemNotFoundException3) { ItemNotFoundException itemNotFoundException2 = itemNotFoundException3; base.WriteError(new ErrorRecord(itemNotFoundException2.ErrorRecord, itemNotFoundException2)); return; } if (!flag) { CmdletProviderContext passThru = cmdletProviderContext; passThru.PassThru = this.PassThru; object[] destination = new object[2]; destination[0] = path; destination[1] = this.Destination; CoreCommandBase.tracer.WriteLine("Moving {0} to {1}", destination); try { string str1 = path; if (!base.SuppressWildcardExpansion) { str1 = WildcardPattern.Escape(path); } base.InvokeProvider.Item.Move(str1, this.Destination, passThru); } catch (PSNotSupportedException pSNotSupportedException5) { PSNotSupportedException pSNotSupportedException4 = pSNotSupportedException5; base.WriteError(new ErrorRecord(pSNotSupportedException4.ErrorRecord, pSNotSupportedException4)); } catch (DriveNotFoundException driveNotFoundException5) { DriveNotFoundException driveNotFoundException4 = driveNotFoundException5; base.WriteError(new ErrorRecord(driveNotFoundException4.ErrorRecord, driveNotFoundException4)); } catch (ProviderNotFoundException providerNotFoundException5) { ProviderNotFoundException providerNotFoundException4 = providerNotFoundException5; base.WriteError(new ErrorRecord(providerNotFoundException4.ErrorRecord, providerNotFoundException4)); } catch (ItemNotFoundException itemNotFoundException5) { ItemNotFoundException itemNotFoundException4 = itemNotFoundException5; base.WriteError(new ErrorRecord(itemNotFoundException4.ErrorRecord, itemNotFoundException4)); } } else { object[] objArray1 = new object[1]; objArray1[0] = path; PSInvalidOperationException pSInvalidOperationException1 = PSTraceSource.NewInvalidOperationException("NavigationResources", "MoveItemInUse", objArray1); base.WriteError(new ErrorRecord(pSInvalidOperationException1.ErrorRecord, pSInvalidOperationException1)); return; } }
protected override void ProcessRecord() { ProviderInfo singleProvider = null; try { singleProvider = base.SessionState.Internal.GetSingleProvider(this.PSProvider); } catch (ProviderNotFoundException providerNotFoundException1) { ProviderNotFoundException providerNotFoundException = providerNotFoundException1; base.WriteError(new ErrorRecord(providerNotFoundException.ErrorRecord, providerNotFoundException)); return; } if (singleProvider != null) { string newDriveConfirmAction = NavigationResources.NewDriveConfirmAction; string newDriveConfirmResourceTemplate = NavigationResources.NewDriveConfirmResourceTemplate; object[] name = new object[3]; name[0] = this.Name; name[1] = singleProvider.FullName; name[2] = this.Root; string str = string.Format(Thread.CurrentThread.CurrentCulture, newDriveConfirmResourceTemplate, name); if (base.ShouldProcess(str, newDriveConfirmAction)) { if (this.Persist && !singleProvider.Name.Equals("FileSystem", StringComparison.OrdinalIgnoreCase)) { ErrorRecord errorRecord = new ErrorRecord(new NotSupportedException(FileSystemProviderStrings.PersistNotSupported), "DriveRootNotNetworkPath", ErrorCategory.InvalidArgument, this); base.ThrowTerminatingError(errorRecord); } PSDriveInfo pSDriveInfo = new PSDriveInfo(this.Name, singleProvider, this.Root, this.Description, base.Credential, this.Persist); try { base.SessionState.Drive.New(pSDriveInfo, this.Scope, this.CmdletProviderContext); } catch (PSNotSupportedException pSNotSupportedException1) { PSNotSupportedException pSNotSupportedException = pSNotSupportedException1; base.WriteError(new ErrorRecord(pSNotSupportedException.ErrorRecord, pSNotSupportedException)); } catch (DriveNotFoundException driveNotFoundException1) { DriveNotFoundException driveNotFoundException = driveNotFoundException1; base.WriteError(new ErrorRecord(driveNotFoundException.ErrorRecord, driveNotFoundException)); } catch (ProviderNotFoundException providerNotFoundException3) { ProviderNotFoundException providerNotFoundException2 = providerNotFoundException3; base.WriteError(new ErrorRecord(providerNotFoundException2.ErrorRecord, providerNotFoundException2)); } catch (PSArgumentException pSArgumentException1) { PSArgumentException pSArgumentException = pSArgumentException1; base.WriteError(new ErrorRecord(pSArgumentException.ErrorRecord, pSArgumentException)); } catch (ItemNotFoundException itemNotFoundException1) { ItemNotFoundException itemNotFoundException = itemNotFoundException1; base.WriteError(new ErrorRecord(itemNotFoundException.ErrorRecord, itemNotFoundException)); } catch (SessionStateOverflowException sessionStateOverflowException) { throw; } catch (SessionStateException sessionStateException1) { SessionStateException sessionStateException = sessionStateException1; base.WriteError(new ErrorRecord(sessionStateException.ErrorRecord, sessionStateException)); } } } }
protected override void ProcessRecord() { object obj = null; string parameterSetName = base.ParameterSetName; string str = parameterSetName; if (parameterSetName != null) { if (str == "Path" || str == "LiteralPath") { try { obj = base.SessionState.Path.SetLocation(this.Path, this.CmdletProviderContext); } catch (PSNotSupportedException pSNotSupportedException1) { PSNotSupportedException pSNotSupportedException = pSNotSupportedException1; base.WriteError(new ErrorRecord(pSNotSupportedException.ErrorRecord, pSNotSupportedException)); } catch (DriveNotFoundException driveNotFoundException1) { DriveNotFoundException driveNotFoundException = driveNotFoundException1; base.WriteError(new ErrorRecord(driveNotFoundException.ErrorRecord, driveNotFoundException)); } catch (ProviderNotFoundException providerNotFoundException1) { ProviderNotFoundException providerNotFoundException = providerNotFoundException1; base.WriteError(new ErrorRecord(providerNotFoundException.ErrorRecord, providerNotFoundException)); } catch (ItemNotFoundException itemNotFoundException1) { ItemNotFoundException itemNotFoundException = itemNotFoundException1; base.WriteError(new ErrorRecord(itemNotFoundException.ErrorRecord, itemNotFoundException)); } catch (PSArgumentException pSArgumentException1) { PSArgumentException pSArgumentException = pSArgumentException1; base.WriteError(new ErrorRecord(pSArgumentException.ErrorRecord, pSArgumentException)); } } else { if (str == "Stack") { try { obj = base.SessionState.Path.SetDefaultLocationStack(this.StackName); } catch (ItemNotFoundException itemNotFoundException3) { ItemNotFoundException itemNotFoundException2 = itemNotFoundException3; base.WriteError(new ErrorRecord(itemNotFoundException2.ErrorRecord, itemNotFoundException2)); } } } } if (this.passThrough && obj != null) { base.WriteObject(obj); } }
} // GetDrivesForProvider #endregion GetDrive #region RemoveDrive /// <summary> /// Removes the drive with the specified name. /// </summary> /// /// <param name="driveName"> /// The name of the drive to remove. /// </param> /// /// <param name="force"> /// Determines whether drive should be forcefully removed even if there was errors. /// </param> /// /// <param name="scopeID"> /// The ID of the scope from which to remove the drive. /// If the scope ID is null or empty, the scope hierarchy will be searched /// starting at the current scope through all the parent scopes to the /// global scope until a drive of the given name is found to remove. /// </param> /// internal void RemoveDrive(string driveName, bool force, string scopeID) { if (driveName == null) { throw PSTraceSource.NewArgumentNullException("driveName"); } PSDriveInfo drive = GetDrive(driveName, scopeID); if (drive == null) { DriveNotFoundException e = new DriveNotFoundException( driveName, "DriveNotFound", SessionStateStrings.DriveNotFound); throw e; } RemoveDrive(drive, force, scopeID); } // RemoveDrive
protected override void ProcessRecord() { Collection <PathInfo> resolvedPSPathFromPSPath; CmdletProviderContext cmdletProviderContext = this.CmdletProviderContext; bool flag = false; bool flag1 = false; string[] path = this.Path; for (int i = 0; i < (int)path.Length; i++) { string str = path[i]; resolvedPSPathFromPSPath = null; try { resolvedPSPathFromPSPath = base.SessionState.Path.GetResolvedPSPathFromPSPath(str, cmdletProviderContext); goto Label0; } catch (PSNotSupportedException pSNotSupportedException1) { PSNotSupportedException pSNotSupportedException = pSNotSupportedException1; base.WriteError(new ErrorRecord(pSNotSupportedException.ErrorRecord, pSNotSupportedException)); } catch (DriveNotFoundException driveNotFoundException1) { DriveNotFoundException driveNotFoundException = driveNotFoundException1; base.WriteError(new ErrorRecord(driveNotFoundException.ErrorRecord, driveNotFoundException)); } catch (ProviderNotFoundException providerNotFoundException1) { ProviderNotFoundException providerNotFoundException = providerNotFoundException1; base.WriteError(new ErrorRecord(providerNotFoundException.ErrorRecord, providerNotFoundException)); } catch (ItemNotFoundException itemNotFoundException1) { ItemNotFoundException itemNotFoundException = itemNotFoundException1; base.WriteError(new ErrorRecord(itemNotFoundException.ErrorRecord, itemNotFoundException)); } } return; Label0: IEnumerator <PathInfo> enumerator = resolvedPSPathFromPSPath.GetEnumerator(); using (enumerator) { while (enumerator.MoveNext()) { PathInfo current = enumerator.Current; bool flag2 = false; try { flag2 = base.SessionState.Path.IsCurrentLocationOrAncestor(current.Path, cmdletProviderContext); } catch (PSNotSupportedException pSNotSupportedException3) { PSNotSupportedException pSNotSupportedException2 = pSNotSupportedException3; base.WriteError(new ErrorRecord(pSNotSupportedException2.ErrorRecord, pSNotSupportedException2)); continue; } catch (DriveNotFoundException driveNotFoundException3) { DriveNotFoundException driveNotFoundException2 = driveNotFoundException3; base.WriteError(new ErrorRecord(driveNotFoundException2.ErrorRecord, driveNotFoundException2)); continue; } catch (ProviderNotFoundException providerNotFoundException3) { ProviderNotFoundException providerNotFoundException2 = providerNotFoundException3; base.WriteError(new ErrorRecord(providerNotFoundException2.ErrorRecord, providerNotFoundException2)); continue; } catch (ItemNotFoundException itemNotFoundException3) { ItemNotFoundException itemNotFoundException2 = itemNotFoundException3; base.WriteError(new ErrorRecord(itemNotFoundException2.ErrorRecord, itemNotFoundException2)); continue; } if (!flag2) { bool flag3 = false; string unresolvedProviderPathFromPSPath = base.GetUnresolvedProviderPathFromPSPath(current.Path); try { flag3 = base.SessionState.Internal.HasChildItems(current.Provider.Name, unresolvedProviderPathFromPSPath, cmdletProviderContext); cmdletProviderContext.ThrowFirstErrorOrDoNothing(); } catch (PSNotSupportedException pSNotSupportedException5) { PSNotSupportedException pSNotSupportedException4 = pSNotSupportedException5; base.WriteError(new ErrorRecord(pSNotSupportedException4.ErrorRecord, pSNotSupportedException4)); continue; } catch (DriveNotFoundException driveNotFoundException5) { DriveNotFoundException driveNotFoundException4 = driveNotFoundException5; base.WriteError(new ErrorRecord(driveNotFoundException4.ErrorRecord, driveNotFoundException4)); continue; } catch (ProviderNotFoundException providerNotFoundException5) { ProviderNotFoundException providerNotFoundException4 = providerNotFoundException5; base.WriteError(new ErrorRecord(providerNotFoundException4.ErrorRecord, providerNotFoundException4)); continue; } catch (ItemNotFoundException itemNotFoundException5) { ItemNotFoundException itemNotFoundException4 = itemNotFoundException5; base.WriteError(new ErrorRecord(itemNotFoundException4.ErrorRecord, itemNotFoundException4)); continue; } if (!this.Recurse && flag3) { string str1 = StringUtil.Format(NavigationResources.RemoveItemWithChildren, current.Path); if (!base.ShouldContinue(str1, null, ref flag, ref flag1)) { continue; } } try { base.SessionState.Internal.RemoveItem(current.Provider.Name, unresolvedProviderPathFromPSPath, this.Recurse, cmdletProviderContext); } catch (PSNotSupportedException pSNotSupportedException7) { PSNotSupportedException pSNotSupportedException6 = pSNotSupportedException7; base.WriteError(new ErrorRecord(pSNotSupportedException6.ErrorRecord, pSNotSupportedException6)); } catch (DriveNotFoundException driveNotFoundException7) { DriveNotFoundException driveNotFoundException6 = driveNotFoundException7; base.WriteError(new ErrorRecord(driveNotFoundException6.ErrorRecord, driveNotFoundException6)); } catch (ProviderNotFoundException providerNotFoundException7) { ProviderNotFoundException providerNotFoundException6 = providerNotFoundException7; base.WriteError(new ErrorRecord(providerNotFoundException6.ErrorRecord, providerNotFoundException6)); } catch (ItemNotFoundException itemNotFoundException7) { ItemNotFoundException itemNotFoundException6 = itemNotFoundException7; base.WriteError(new ErrorRecord(itemNotFoundException6.ErrorRecord, itemNotFoundException6)); } } else { object[] objArray = new object[1]; objArray[0] = current.Path; PSInvalidOperationException pSInvalidOperationException = PSTraceSource.NewInvalidOperationException("NavigationResources", "RemoveItemInUse", objArray); base.WriteError(new ErrorRecord(pSInvalidOperationException.ErrorRecord, pSInvalidOperationException)); } } return; } }
private PSDriveInfo GetDrive(string name, bool automount) { if (name == null) { throw PSTraceSource.NewArgumentNullException("name"); } PSDriveInfo result = null; // Start searching through the scopes for the drive until the drive // is found or the global scope is reached. SessionStateScopeEnumerator scopeEnumerator = new SessionStateScopeEnumerator(CurrentScope); int scopeID = 0; foreach (SessionStateScope processingScope in scopeEnumerator) { result = processingScope.GetDrive(name); if (result != null) { if (result.IsAutoMounted) { // Validate or remove the auto-mounted drive if (!ValidateOrRemoveAutoMountedDrive(result, processingScope)) { result = null; } } if (result != null) { s_tracer.WriteLine("Drive found in scope {0}", scopeID); break; } } // Increment the scope ID ++scopeID; } // foreach scope if (result == null && automount) { result = AutomountBuiltInDrive(name); } if (result == null && this == ExecutionContext.TopLevelSessionState) { result = AutomountFileSystemDrive(name); } if (result == null) { DriveNotFoundException driveNotFound = new DriveNotFoundException( name, "DriveNotFound", SessionStateStrings.DriveNotFound); throw driveNotFound; } return result; } // GetDrive
protected override void ProcessRecord() { string[] path = this.Path; for (int i = 0; i < (int)path.Length; i++) { string str = path[i]; string str1 = null; try { str1 = base.SessionState.Path.Combine(str, this.ChildPath, this.CmdletProviderContext); } catch (PSNotSupportedException pSNotSupportedException1) { PSNotSupportedException pSNotSupportedException = pSNotSupportedException1; base.WriteError(new ErrorRecord(pSNotSupportedException.ErrorRecord, pSNotSupportedException)); goto Label0; } catch (DriveNotFoundException driveNotFoundException1) { DriveNotFoundException driveNotFoundException = driveNotFoundException1; base.WriteError(new ErrorRecord(driveNotFoundException.ErrorRecord, driveNotFoundException)); goto Label0; } catch (ProviderNotFoundException providerNotFoundException1) { ProviderNotFoundException providerNotFoundException = providerNotFoundException1; base.WriteError(new ErrorRecord(providerNotFoundException.ErrorRecord, providerNotFoundException)); goto Label0; } catch (ItemNotFoundException itemNotFoundException1) { ItemNotFoundException itemNotFoundException = itemNotFoundException1; base.WriteError(new ErrorRecord(itemNotFoundException.ErrorRecord, itemNotFoundException)); goto Label0; } if (!this.Resolve) { if (str1 != null) { base.WriteObject(str1); } } else { Collection <PathInfo> resolvedPSPathFromPSPath = null; try { resolvedPSPathFromPSPath = base.SessionState.Path.GetResolvedPSPathFromPSPath(str1, this.CmdletProviderContext); } catch (PSNotSupportedException pSNotSupportedException3) { PSNotSupportedException pSNotSupportedException2 = pSNotSupportedException3; base.WriteError(new ErrorRecord(pSNotSupportedException2.ErrorRecord, pSNotSupportedException2)); goto Label0; } catch (DriveNotFoundException driveNotFoundException3) { DriveNotFoundException driveNotFoundException2 = driveNotFoundException3; base.WriteError(new ErrorRecord(driveNotFoundException2.ErrorRecord, driveNotFoundException2)); goto Label0; } catch (ProviderNotFoundException providerNotFoundException3) { ProviderNotFoundException providerNotFoundException2 = providerNotFoundException3; base.WriteError(new ErrorRecord(providerNotFoundException2.ErrorRecord, providerNotFoundException2)); goto Label0; } catch (ItemNotFoundException itemNotFoundException3) { ItemNotFoundException itemNotFoundException2 = itemNotFoundException3; base.WriteError(new ErrorRecord(itemNotFoundException2.ErrorRecord, itemNotFoundException2)); goto Label0; } for (int j = 0; j < resolvedPSPathFromPSPath.Count; j++) { try { if (resolvedPSPathFromPSPath[j] != null) { base.WriteObject(resolvedPSPathFromPSPath[j].Path); } } catch (PSNotSupportedException pSNotSupportedException5) { PSNotSupportedException pSNotSupportedException4 = pSNotSupportedException5; base.WriteError(new ErrorRecord(pSNotSupportedException4.ErrorRecord, pSNotSupportedException4)); } catch (DriveNotFoundException driveNotFoundException5) { DriveNotFoundException driveNotFoundException4 = driveNotFoundException5; base.WriteError(new ErrorRecord(driveNotFoundException4.ErrorRecord, driveNotFoundException4)); } catch (ProviderNotFoundException providerNotFoundException5) { ProviderNotFoundException providerNotFoundException4 = providerNotFoundException5; base.WriteError(new ErrorRecord(providerNotFoundException4.ErrorRecord, providerNotFoundException4)); } catch (ItemNotFoundException itemNotFoundException5) { ItemNotFoundException itemNotFoundException4 = itemNotFoundException5; base.WriteError(new ErrorRecord(itemNotFoundException4.ErrorRecord, itemNotFoundException4)); } } } Label0: continue; } }