symlink? reports false

S

Simon Strandgaard

File.stat(name).symlink? keeps returning false, even though
I do stat on a real symlink file.

Shouldn't symlink? return true in on the 'xyzxyzxyz'..
see attached snippet

--
Simon Strandgaard

server> ruby a.rb
filename=/usr/home/neoneye/kode/editor/projects/regexp_engine/test/a.rb
symlink?=false
type=file
#<File::Stat dev=0x413, ino=456591, mode=0100644, nlink=1, uid=1001, gid=1001, rdev=0x1bab02, size=358, blksize=16384, blocks=4, atime=Sun Apr 11 00:51:15 CEST 2004, mtime=Sun Apr 11 00:48:50 CEST 2004, ctime=Sun Apr 11 00:48:50 CEST 2004>
----------------------------------------
filename=xyzxyzxyz
symlink?=false
type=link
#<File::Stat dev=0x413, ino=456591, mode=0100644, nlink=1, uid=1001, gid=1001, rdev=0x1bab02, size=358, blksize=16384, blocks=4, atime=Sun Apr 11 00:51:15 CEST 2004, mtime=Sun Apr 11 00:48:50 CEST 2004, ctime=Sun Apr 11 00:48:50 CEST 2004>
server> expand -t2 a.rb
require 'fileutils'
def info(name)
stat = File.stat(name)
ftype = File.ftype(name)
issym = File.stat(name).symlink?
puts "filename=#{name}\nsymlink?=#{issym}\ntype=#{ftype}\n#{stat.inspect}"
end
absname = File.expand_path(__FILE__)
linkname = "xyzxyzxyz"
FileUtils.ln_s(absname, linkname)
info(absname)
puts("-"*40)
info(linkname)
FileUtils.rm(linkname)
server>
 
S

Simon Strandgaard

File.stat(name).symlink? keeps returning false, even though
I do stat on a real symlink file.

Shouldn't symlink? return true in on the 'xyzxyzxyz'..
see attached snippet

How about File.lstat(name).symlink?

Thansk for the quick reply.. that works ;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top