I am getting strange behavior running the following test case:
Create a file on filesystem (created D:/auz.dat)
Check to see if the created file exists by running
File.exist?(“D:/auz.dat”)
The code returns True
Run File.exist?(“D:/aux.dat”) (this file does not exists and should
return false)
It returns True.
The only file that should exist is auz.dat. Looking for auu.dat or other
variations do not consistently return false and looking for aux.dat
falsely returns true every time.
File.file? seems to act the same.
I am new to Ruby and am seeing this behavior in windows (one-click
install) on any version higher than 1.8.2. On 1.8.2 it behaves as I
think it should. I am currently using 1.8.5 and cannot recreate this
behavior in linux - it seems to be specific to the windows installs I
have tried it on.
So any feedback would be appreciated - it could just be something simple
I am doing wrong. Thanks in advance.
(small test I wrote for this)
def FileExists
fileToTest = "D:/aux.dat"
puts 'Checking for file: ' + fileToTest
if File.exist?(fileToTest)
puts 'file is there'
else
puts 'file not found'
end
I am getting strange behavior running the following test case:
Create a file on filesystem (created D:/auz.dat)
Check to see if the created file exists by running
File.exist?(“D:/auz.dat”)
The code returns True
Run File.exist?(“D:/aux.dat”) (this file does not exists and should
return false)
It returns True.
The only file that should exist is auz.dat. Looking for auu.dat or other
variations do not consistently return false and looking for aux.dat
falsely returns true every time.
File.file? seems to act the same.
I am new to Ruby and am seeing this behavior in windows (one-click
install) on any version higher than 1.8.2. On 1.8.2 it behaves as I
think it should. I am currently using 1.8.5 and cannot recreate this
behavior in linux - it seems to be specific to the windows installs I
have tried it on.
So any feedback would be appreciated - it could just be something simple
I am doing wrong. Thanks in advance.
(small test I wrote for this)
def FileExists
fileToTest = "D:/aux.dat"
puts 'Checking for file: ' + fileToTest
if File.exist?(fileToTest)
puts 'file is there'
else
puts 'file not found'
end
end
Well, I was waiting for somebody more experienced with Windows to chime
in, but…
This is nothing to do with Ruby. “aux” is a reserved device name in
Windows. There are others: con, prn, nul, for example. These device
names look like filenames but they always exist and they exist in every
directory. Adding an extension doesn’t change anything.
Thanks for the info. This makes sense and it was just a fluke that I was
testing for aux etc. It looks like I’m good now.
Tim H. wrote:
Well, I was waiting for somebody more experienced with Windows to chime
in, but…
This is nothing to do with Ruby. “aux” is a reserved device name in
Windows. There are others: con, prn, nul, for example. These device
names look like filenames but they always exist and they exist in every
directory. Adding an extension doesn’t change anything.