Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb3bc4ff

Browse files
authored
Use absolute path inFileSystemProvider.CreateDirectory (#24615)
1 parentcbafa5a commitb3bc4ff

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

‎src/System.Management.Automation/namespaces/FileSystemProvider.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2665,12 +2665,6 @@ private void CreateDirectory(string path, bool streamOutput)
26652665
!string.IsNullOrEmpty(path),
26662666
"The caller should verify path");
26672667

2668-
// Get the parent path
2669-
stringparentPath=GetParentPath(path,null);
2670-
2671-
// The directory name
2672-
stringchildName=GetChildName(path);
2673-
26742668
ErrorRecorderror=null;
26752669
if(!Force&&ItemExists(path,outerror))
26762670
{
@@ -2700,7 +2694,7 @@ private void CreateDirectory(string path, bool streamOutput)
27002694

27012695
if(ShouldProcess(resource,action))
27022696
{
2703-
varresult=Directory.CreateDirectory(Path.Combine(parentPath,childName));
2697+
varresult=Directory.CreateDirectory(path);
27042698

27052699
if(streamOutput)
27062700
{

‎test/powershell/Modules/Microsoft.PowerShell.Management/FileSystem.Tests.ps1

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,6 +1206,20 @@ Describe "Extended FileSystem Item/Content Cmdlet Provider Tests" -Tags "Feature
12061206
$result.Name| Should-BeExactly$testDir
12071207
}
12081208

1209+
It"Verify Directory creation when path relative to current PSDrive is empty" {
1210+
try {
1211+
$rootDir=New-Item"NewDirectory"-ItemType Directory-Force
1212+
$rootPath=$rootDir.FullName
1213+
$newPSDrive=New-PSDrive-Name"NewPSDrive"-PSProvider FileSystem-Root$rootPath
1214+
1215+
$result=New-Item-Path"NewPSDrive:\"-ItemType Directory-Force
1216+
$result.FullName.TrimEnd("/\")| Should-BeExactly$newPSDrive.Root
1217+
}
1218+
finally {
1219+
Remove-PSDrive-Name"NewPSDrive"-Force-ErrorAction SilentlyContinue
1220+
}
1221+
}
1222+
12091223
It"Verify File + Value" {
12101224
$result=New-Item-Path.-ItemType File-Name$testFile-Value"Some String"
12111225
$content=Get-Content-Path$testFile

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp