Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,9 @@ protected override ProviderInfo Start(ProviderInfo providerInfo)
providerInfo.Home = homeDirectory;
}
else
{
s_tracer.WriteLine("Not setting home directory {0} - does not exist", homeDirectory);
}
}
}

Expand Down Expand Up @@ -965,7 +967,9 @@ protected override Collection<PSDriveInfo> InitializeDefaultDrives()
}

if (skipDuplicate)
{
continue;
}

// Create a new VirtualDrive for each logical drive
PSDriveInfo newPSDriveInfo =
Expand Down Expand Up @@ -1101,7 +1105,9 @@ protected override bool IsValidPath(string path)
return false;
}
else
{
throw;
}
}

return true;
Expand Down Expand Up @@ -1565,7 +1571,9 @@ private void GetPathItems(
false);
}
else
{
WriteItemObject(fsinfo, path, false);
}
}
}
}
Expand Down Expand Up @@ -1704,9 +1712,13 @@ private void Dir(
else
{
if (filesystemInfo is FileInfo)
{
WriteItemObject(filesystemInfo, filesystemInfo.FullName, false);
}
else
{
WriteItemObject(filesystemInfo, filesystemInfo.FullName, true);
}
}
}
}
Expand Down Expand Up @@ -1859,11 +1871,15 @@ private FlagsExpression<FileAttributes> FormatAttributeSwitchParameters()
public static string Mode(PSObject instance)
{
if (instance == null)
{
return string.Empty;
}

FileSystemInfo fileInfo = (FileSystemInfo)instance.BaseObject;
if (fileInfo == null)
{
return string.Empty;
}

char[] mode = new char[6];
mode[0] = (fileInfo.Attributes & FileAttributes.Directory) == FileAttributes.Directory ? 'd' : '-';
Expand Down Expand Up @@ -1912,7 +1928,6 @@ protected override void RenameItem(
path = NormalizePath(path);

if (string.IsNullOrEmpty(newName))

{
throw PSTraceSource.NewArgumentException("newName");
}
Expand Down Expand Up @@ -2127,9 +2142,13 @@ protected override void NewItem(
{
string action = null;
if (itemType == ItemType.SymbolicLink)
{
action = FileSystemProviderStrings.NewItemActionSymbolicLink;
}
else if (itemType == ItemType.HardLink)
{
action = FileSystemProviderStrings.NewItemActionHardLink;
}

string resource = StringUtil.Format(FileSystemProviderStrings.NewItemActionTemplate, path);

Expand Down Expand Up @@ -2223,7 +2242,9 @@ protected override void NewItem(
WriteError(new ErrorRecord(exception, "NewItemDeleteIOError", ErrorCategory.WriteError, path));
}
else
{
throw;
}
}
}
else
Expand Down Expand Up @@ -2387,7 +2408,9 @@ protected override void NewItem(
WriteError(new ErrorRecord(exception, "NewItemDeleteIOError", ErrorCategory.WriteError, path));
}
else
{
throw;
}
}
}
}
Expand Down Expand Up @@ -2435,7 +2458,9 @@ protected override void NewItem(
WriteError(new ErrorRecord(exception, "NewItemCreateIOError", ErrorCategory.WriteError, path));
}
else
{
throw;
}
}
}
}
Expand Down Expand Up @@ -3773,7 +3798,9 @@ private void CopyFileInfoItem(FileInfo file, string destinationPath, bool force,
WriteError(new ErrorRecord(unAuthorizedAccessException, "CopyFileInfoItemUnauthorizedAccessError", ErrorCategory.PermissionDenied, file));
}
else
{
throw;
}
}

file.CopyTo(destinationPath, true);
Expand Down Expand Up @@ -3928,15 +3955,21 @@ private ArrayList GetRemoteSourceAlternateStreams(System.Management.Automation.P

private void InitializeFunctionPSCopyFileFromRemoteSession(System.Management.Automation.PowerShell ps)
{
if ((ps == null) || !ValidRemoteSessionForScripting(ps.Runspace)) { return; }
if ((ps == null) || !ValidRemoteSessionForScripting(ps.Runspace))
{
return;
}

ps.AddScript(CopyFileRemoteUtils.AllCopyFromRemoteScripts);
SafeInvokeCommand.Invoke(ps, this, null, false);
}

private void RemoveFunctionsPSCopyFileFromRemoteSession(System.Management.Automation.PowerShell ps)
{
if ((ps == null) || !ValidRemoteSessionForScripting(ps.Runspace)) { return; }
if ((ps == null) || !ValidRemoteSessionForScripting(ps.Runspace))
{
return;
}

string remoteScript = @"
Microsoft.PowerShell.Management\Remove-Item function:PSCopyFromSessionHelper -ea SilentlyContinue -Force
Expand All @@ -3948,7 +3981,10 @@ private void RemoveFunctionsPSCopyFileFromRemoteSession(System.Management.Automa

private bool ValidRemoteSessionForScripting(Runspace runspace)
{
if (!(runspace is RemoteRunspace)) { return false; }
if (!(runspace is RemoteRunspace))
{
return false;
}

PSLanguageMode languageMode = runspace.SessionStateProxy.LanguageMode;
if (languageMode == PSLanguageMode.ConstrainedLanguage || languageMode == PSLanguageMode.NoLanguage)
Expand Down