runtime icon indicating copy to clipboard operation
runtime copied to clipboard

Creating files with whitespace names on Linux throws an exception

Open ianhays opened this issue 11 years ago • 2 comments

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

ianhays avatar Jun 30 '15 22:06 ianhays

This is related to dotnet/runtime#14772.

stephentoub avatar Jul 02 '15 14:07 stephentoub

@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?

stephentoub avatar Jul 09 '15 13:07 stephentoub