Cliffano Subagio
unread,Sep 9, 2010, 2:41:56 AM9/9/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to nod...@googlegroups.com
Hi,
I was testing an app that uses realpathSync, and I found out that it returns different value compared to realpath itself on certain path settings.
1. mkdir -p /a/b/c/d/e/f/g/h/i/j
2. touch /a/b/c/d/e/f/g/h/i/j/x.txt
3. cd /a/b
4. ln -s /a/b/c/d/e/f current
I then ran the following code:
================
var fs = require('fs'),
sys = require('sys');
sys.puts(fs.realpathSync('/a/b/current/g/h/i/j/x.txt'));
================
I got the result
/a/b/c/d/e/f
Whereas running
realpath /a/b/current/g/h/i/j/x.txt
gave me
/a/b/c/d/e/f/g/h/i/j/x.txt
However, when I redid the same thing (steps 1, 2, 3) but with a different way of creating the symlink on step 4
4. ln -s c/d/e/f current
I got identical result from both the node code and realpath command, the result was
/a/b/c/d/e/f/g/h/i/j/x.txt
Could this be a bug with node realpathSync? or did I misunderstand how realpathSync is supposed to work?
Tested on Ubuntu Lucid with node 0.2.0 .
Cheers,
Cliff.