Actions
Bug #10577
closedConfusing behavior of File.open with bad filenames in windows
    Bug #10577:
    Confusing behavior of File.open with bad filenames in windows
  
Description
I've used a colon in a filename in my script and confronted with a confusing behavior when ran program in windows. Ruby ignored the wrong part of a filename and created a file with a shortened name. I find it very dangerous, that a program can silently touch a file with a different name and overwrite it.
File.open('c:\a:b.txt', 'w') do |fw|
fw.puts 'test'
end
It creates a file named c:\a which is... empty. No exception is raised, but a file is created and content is missing.
I guess my version of ruby (actually both 2.0.0p451 and 2.1.5p273) is for mingw platform (I've downloaded them from rubyinstaller.org)
        
           Updated by usa (Usaku NAKAMURA) almost 11 years ago
          Updated by usa (Usaku NAKAMURA) almost 11 years ago
          
          
        
        
      
      - Status changed from Open to Rejected
Google "NTFS Alternate Data Streams".
Actions