Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Remove catch clause from GetIsCaseSensitiveByProbing
  • Loading branch information
lambdageek committed Jun 21, 2021
commit ad2e8f2eb68046e748920d8d6961c6ff5fd4ee43
21 changes: 6 additions & 15 deletions src/libraries/System.IO.FileSystem/tests/FileSystemTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,21 +139,12 @@ protected void ReadOnly_FileSystemHelper(Action<string> testAction, string subDi
/// </remarks>
protected static bool GetIsCaseSensitiveByProbing(string probingDirectory)
{
try
{
string pathWithUpperCase = Path.Combine(probingDirectory, "CASESENSITIVETEST" + Guid.NewGuid().ToString("N"));
using (new FileStream(pathWithUpperCase, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None, 0x1000, FileOptions.DeleteOnClose))
{
string lowerCased = pathWithUpperCase.ToLowerInvariant();
return !File.Exists(lowerCased);
}
}
catch
{
// In case something goes wrong (e.g. temp pointing to a privilieged directory), we don't
// want to fail just because of a casing test, so we assume case-insensitive-but-preserving.
return false;
}
string pathWithUpperCase = Path.Combine(probingDirectory, "CASESENSITIVETEST" + Guid.NewGuid().ToString("N"));
using (new FileStream(pathWithUpperCase, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None, 0x1000, FileOptions.DeleteOnClose))
{
string lowerCased = pathWithUpperCase.ToLowerInvariant();
return !File.Exists(lowerCased);
}
}
}
}