Issue #1594 has been updated by Hiroshi NAKAMURA.

Target version set to 1.9.3


----------------------------------------
Bug #1594: Dir.foreach() mistakenly throws EINVAL in Windows
http://redmine.ruby-lang.org/issues/1594

Author: Barry DeZonia
Status: Assigned
Priority: Normal
Assignee: Akio Tajima
Category: 
Target version: 1.9.3
ruby -v: ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]


=begin
 On Windows 2003 Server (64 bit) I use the attached script to trim files off a disk backup. This code runs fine for days and days but infrequently crashes on the same line of the script: (line 137 - Dir.foreach(copyFullDirName) do | dirEntry |).
 
 The backtrace is:
 D:/BackupScripts/trimMachines.rb:137:in `open': Invalid argument - x:\.\document
 s and settings\pdculbert\Desktop\Pedram stats\Raw BBS Data by State\FCV30ALL_TES
 T\ComDyn (Errno::EINVAL)
         from D:/BackupScripts/trimMachines.rb:137:in `foreach'
         from D:/BackupScripts/trimMachines.rb:137:in `trimDirectory'
         from D:/BackupScripts/trimMachines.rb:142:in `trimDirectory'
         from D:/BackupScripts/trimMachines.rb:137:in `foreach'
         from D:/BackupScripts/trimMachines.rb:137:in `trimDirectory'
         from D:/BackupScripts/trimMachines.rb:142:in `trimDirectory'
         from D:/BackupScripts/trimMachines.rb:137:in `foreach'
         from D:/BackupScripts/trimMachines.rb:137:in `trimDirectory'
          ... 19 levels...
         from D:/BackupScripts/trimMachines.rb:200:in `trimMachines'
         from D:/BackupScripts/trimMachines.rb:187:in `foreach'
         from D:/BackupScripts/trimMachines.rb:187:in `trimMachines'
         from D:/BackupScripts/trimMachines.rb:253
 
 When I check out if the path specified is invalid it in fact exists, its file permissions are correct, etc. The biggest issue (I think) is that the directory contains 121,954 files. Note that the script loops over this directory a number of times successfully before it crashes on one pass some days (or weeks) later.
 
 I've tested that the "x:\.\" notation is fine. The directory recursion level is only 8 levels and I don't get a stack too deep error.
 
 Along the "x:\.\documents and settings\pdculbert\Desktop\Pedram stats\Raw BBS Data by State\FCV30ALL_TEST\ComDyn" path on the hard drive:
 
 . contains 4 entries
 documents and settings contains 17 entries
 pdculbert contains 221 entries
 Desktop contains 69 entries
 Pedram stats contains 16 entries
 Raw BBS Data by State contains 82 entries
 FCV30ALL_TEST contains 5 entries
 ComDyn contains 121,956 entries
=end



-- 
http://redmine.ruby-lang.org