Skip to content

Commit ef47025

Browse files
committed
Address code review feedback
1 parent 0183954 commit ef47025

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

src/libraries/Common/src/Interop/Unix/System.Native/Interop.MkDir.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ internal static partial class Sys
1414

1515
internal static int MkDir(ReadOnlySpan<char> path, int mode)
1616
{
17-
var converter = new ValueUtf8Converter(stackalloc byte[DefaultPathBufferSize]);
17+
using ValueUtf8Converter converter = new(stackalloc byte[DefaultPathBufferSize]);
1818
int result = MkDir(ref MemoryMarshal.GetReference(converter.ConvertAndTerminateString(path)), mode);
19-
converter.Dispose();
2019
return result;
2120
}
2221
}

src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Unix.cs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -300,26 +300,19 @@ public static void CreateDirectory(string fullPath)
300300
}
301301
else if (errorInfo.Error == Interop.Error.ENOENT) // Some parts of the path don't exist yet.
302302
{
303-
// Try create parents bottom to top and track those that could not
304-
// be created due to missing parents. Then create them top to bottom.
305-
ValueListBuilder<int> stackDir = new(stackalloc int[32]); // 32 arbitrarily chosen
306-
try
307-
{
308-
CreateParentsAndDirectory(fullPath, ref stackDir);
309-
}
310-
finally
311-
{
312-
stackDir.Dispose();
313-
}
303+
CreateParentsAndDirectory(fullPath);
314304
}
315305
else
316306
{
317307
throw Interop.GetExceptionForIoErrno(errorInfo, fullPath, isDirectory: true);
318308
}
319309
}
320310

321-
private static void CreateParentsAndDirectory(string fullPath, ref ValueListBuilder<int> stackDir)
311+
private static void CreateParentsAndDirectory(string fullPath)
322312
{
313+
// Try create parents bottom to top and track those that could not
314+
// be created due to missing parents. Then create them top to bottom.
315+
using ValueListBuilder<int> stackDir = new(stackalloc int[32]); // 32 arbitrarily chosen
323316
stackDir.Append(fullPath.Length);
324317

325318
int i = fullPath.Length - 1;

0 commit comments

Comments
 (0)