Hello everyone, does someone know a way to get the real path of a symlink? I explain: -I have a file '/home/aPath/test.txt' -I have a symlink '/home/aPath/link' pointing on test.txt I would like to see if the symlink really point on the file and may be, get the real path of it, is there a way to do it? If someone have more information I would like to discuss about it ! :) Valentin
Specifically, there is DiskStore>>isSymlink: but the FilePlugin doesn't seem to have a primitive for the readlink(2) function of the libc On 20 April 2016 at 15:53, Valentin Ryckewaert < valentin.ryckewaert@gmail.com> wrote:
Hello everyone,
does someone know a way to get the real path of a symlink?
I explain: -I have a file '/home/aPath/test.txt' -I have a symlink '/home/aPath/link' pointing on test.txt I would like to see if the symlink really point on the file and may be, get the real path of it, is there a way to do it?
If someone have more information I would like to discuss about it ! :)
Valentin
Damien Pollet <damien.pollet+pharo@gmail.com> writes:
Specifically, there is DiskStore>>isSymlink: but the FilePlugin doesn't seem to have a primitive for the readlink(2) function of the libc
I guess this is work for Mariano then :-) -- Damien Cassou http://damiencassou.seasidehosting.st "Success is the ability to go from one failure to another without losing enthusiasm." --Winston Churchill
it has it. this is how is done in mac: *isSymlink = [[fileAttributes objectForKey: NSFileType] isEqualToString: NSFileTypeSymbolicLink] ? 1 : 0; and this how is done in linux: stat(unixPath, &statBuf) && lstat(unixPath, &statBuf) ... *isSymlink = S_ISLNK(statBuf.st_mode); ⦠and in windows is always false. Esteban
On 20 Apr 2016, at 16:36, Damien Cassou <damien.cassou@inria.fr> wrote:
Damien Pollet <damien.pollet+pharo@gmail.com> writes:
Specifically, there is DiskStore>>isSymlink: but the FilePlugin doesn't seem to have a primitive for the readlink(2) function of the libc
I guess this is work for Mariano then :-)
-- Damien Cassou http://damiencassou.seasidehosting.st
"Success is the ability to go from one failure to another without losing enthusiasm." --Winston Churchill
Esteban Lorenzano <estebanlm@gmail.com> writes:
it has it. this is how is done in mac:
*isSymlink = [[fileAttributes objectForKey: NSFileType] isEqualToString: NSFileTypeSymbolicLink] ? 1 : 0;
and this how is done in linux:
stat(unixPath, &statBuf) && lstat(unixPath, &statBuf) ... *isSymlink = S_ISLNK(statBuf.st_mode);
⦠and in windows is always false.
ok for isSymlink, but how do you get to the file pointed to by the symlink? Damien says it's impossible with current FilePlugin. -- Damien Cassou http://damiencassou.seasidehosting.st "Success is the ability to go from one failure to another without losing enthusiasm." --Winston Churchill
yes it is. but you can create an FFI function to http://linux.die.net/man/2/readlink to get that :) Esteban
On 20 Apr 2016, at 18:11, Damien Cassou <Damien.Cassou@inria.fr> wrote:
Esteban Lorenzano <estebanlm@gmail.com> writes:
it has it. this is how is done in mac:
*isSymlink = [[fileAttributes objectForKey: NSFileType] isEqualToString: NSFileTypeSymbolicLink] ? 1 : 0;
and this how is done in linux:
stat(unixPath, &statBuf) && lstat(unixPath, &statBuf) ... *isSymlink = S_ISLNK(statBuf.st_mode);
⦠and in windows is always false.
ok for isSymlink, but how do you get to the file pointed to by the symlink? Damien says it's impossible with current FilePlugin.
-- Damien Cassou http://damiencassou.seasidehosting.st
"Success is the ability to go from one failure to another without losing enthusiasm." --Winston Churchill
In Windows, there are junctions, which are more or less equivalent. https://msdn.microsoft.com/en-us/library/windows/desktop/aa365006(v=vs.85).a... https://msdn.microsoft.com/en-us/library/windows/desktop/aa365503(v=vs.85).a... Phil On Wed, Apr 20, 2016 at 6:23 PM, Esteban Lorenzano <estebanlm@gmail.com> wrote:
yes it is. but you can create an FFI function to http://linux.die.net/man/2/readlink to get that :)
Esteban
On 20 Apr 2016, at 18:11, Damien Cassou <Damien.Cassou@inria.fr> wrote:
Esteban Lorenzano <estebanlm@gmail.com> writes:
it has it. this is how is done in mac:
*isSymlink = [[fileAttributes objectForKey: NSFileType] isEqualToString: NSFileTypeSymbolicLink] ? 1 : 0;
and this how is done in linux:
stat(unixPath, &statBuf) && lstat(unixPath, &statBuf) ... *isSymlink = S_ISLNK(statBuf.st_mode);
⦠and in windows is always false.
ok for isSymlink, but how do you get to the file pointed to by the symlink? Damien says it's impossible with current FilePlugin.
-- Damien Cassou http://damiencassou.seasidehosting.st
"Success is the ability to go from one failure to another without losing enthusiasm." --Winston Churchill
2016-04-21 3:43 GMT-03:00 phil@highoctane.be <phil@highoctane.be>:
In Windows, there are junctions, which are more or less equivalent.
https://msdn.microsoft.com/en-us/library/windows/desktop/aa365006(v=vs.85).a...
Yeap, I use it with this tool. http://schinagl.priv.at/nt/hardlinkshellext/linkshellextension.html Esteban A. Maringolo
Valentin can you open a ticket and add all the information there? Thanks Le 20/4/16 à 15:53, Valentin Ryckewaert a écrit :
Hello everyone,
does someone know a way to get the real path of a symlink?
I explain: -I have a file '/home/aPath/test.txt' -I have a symlink '/home/aPath/link' pointing on test.txt I would like to see if the symlink really point on the file and may be, get the real path of it, is there a way to do it?
If someone have more information I would like to discuss about it ! :)
Valentin
participants (7)
-
Damien Cassou -
Damien Pollet -
Esteban A. Maringolo -
Esteban Lorenzano -
phil@highoctane.be -
stepharo -
Valentin Ryckewaert