runtime
runtime copied to clipboard
Creating files with whitespace names on Linux throws an exception
Creating files with whitespace names on Linux throws an exception when it should allow the operation. The following lines each throw an exception:
File.Create(Path.Combine(TestDirectory, "\n")); //throws
File.Create(Path.Combine(TestDirectory, " ")); //throws
File.Create(Path.Combine(TestDirectory, " ")); //throws
The stack trace for a unit test:
System.UnauthorizedAccessException : Access to the path '/home/ianha/kcorefx/Directory_GetFileSystemEntries_str/' is denied.
Stack Trace:
at Interop.CheckIo(Int64 result, String path, Boolean isDirectory, Func`2 errorRewriter)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
at System.IO.UnixFileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, FileStream parent)
at System.IO.UnixFileSystem.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, FileStream parent)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
at System.IO.File.Create(String path, Int32 bufferSize)
at System.IO.File.Create(String path)
at Directory_GetFileSystemEntries_str.UnixFileNameWithSpaces()
And of course, creating a file in the same directory with a spaceless name not throw an exception:
File.Create(Path.Combine(TestDirectory, "cat")); //this is fine
This is related to dotnet/runtime#14772.
@ianhays, this was reopened for dotnet/corefx#2281, but I don't believe it's actually still an issue. From reading that PR, I believe the ActiveIssue tests linking to this one are actually working as-is or are failing for reasons unrelated to this issue. Can you confirm?