From: Nobu
>
> I'm not sure if this works on Win9X or not.
>
> [.. patch ..]


It fixes the bug; - I'm not sure if it should do more?

Here are some results (after patching) if they're of any help.

   # Windows 98 (4.10.2222)
   # ruby 1.9.0 (2005-10-31) [i586-bccwin32]  (+ patch)


p test(?-, 'D:\ruby\bin\ri.bat', 'D:\ruby\bin\irb.bat')        # plain files
#-> false  (expected - Was "true" before patching)

p test(?-, 'D:\RUBY\BIN\IRBBAT~1.PIF', 'D:\ruby\bin\irb.bat')  # s/c to DOS file
#-> false  ( but file1 is a shortcut to file 2 ... ? hard link ? )

#---------

# Try a link /without/ the .lnk extension
p File.exist?('D:\ruby\DfB\Win32API\winver\init.rb')   #-> false  (expected)

sc   =        'D:\ruby\DfB\Win32API\winver\init.rb.lnk'        # s/c (normal)
p [ File.exist?(sc),   File.size(sc) ]                 #->  [true, 467]  <-------#
file =        'D:\ruby\DfB\Win32API\win32module\win32\init.rb' # -> real file
p [ File.exist?(file), File.size(file) ]               #->  [true, 2597]
p test(?-, sc, file)                                           # s/c to dir
#-> false  ( but file1 is a shortcut to file 2 ... ? hard link ? )

#---------

dir_sc, dir = 'D:\ruby\SOURCE_CODE\WWW.LNK', 'E:\CVS_temp\www'
p [ File.exist?(dir_sc), File.exist?(dir) ]            #->  [true, true]
p test(?-, dir_sc, dir)                                        # s/c to dir
#-> false  ( but file1 is a shortcut to /dir/ 2 ... ? hard link ? )


.LNK & .PIF binary files are opened directly.

#=====
# Open and read 'init.rb.lnk' reads .lnk file (binary), /not/ linked-to file.
File.open(sc, 'rb') {|shcut| p shcut.read.size}        #->         467  <--------#
#=====

IMO, this behaviour is normal, for Windows.
A .LNK file is opened directly in Notepad.
SciTE editor and UltraEdit normally open directly but both have
options to redirect to open the real file, suggesting that some
extra work needs to be done in redirecting.

During a directory search I would have to use something like:
   ['.PIF','.LNK'}.include?(File.extname(sc).upcase)
 if I needed to avoid them.


Finding a .LNK target is ugly, AFAICS:
http://www.codeguru.com/Cpp/COM-Tech/shell/article.php/c1337


daz