[Pharo-Users] Symbolic links

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

[Pharo-Users] Symbolic links

Valentin Ryckewaert
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
Reply | Threaded
Open this post in threaded view
|

Re: [Pharo-Users] Symbolic links

Damien Pollet-2
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 <[hidden email]> 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

Reply | Threaded
Open this post in threaded view
|

Re: [Pharo-Users] Symbolic links

Damien Cassou-2
Damien Pollet <[hidden email]> 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

Reply | Threaded
Open this post in threaded view
|

Re: [Pharo-Users] Symbolic links

EstebanLM
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 <[hidden email]> wrote:
>
> Damien Pollet <[hidden email]> 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
>


Reply | Threaded
Open this post in threaded view
|

Re: [Pharo-Users] Symbolic links

Damien Cassou-2
Esteban Lorenzano <[hidden email]> 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

Reply | Threaded
Open this post in threaded view
|

Re: [Pharo-Users] Symbolic links

EstebanLM
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 <[hidden email]> wrote:
>
> Esteban Lorenzano <[hidden email]> 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


Reply | Threaded
Open this post in threaded view
|

Re: [Pharo-Users] Symbolic links

philippeback

On Wed, Apr 20, 2016 at 6:23 PM, Esteban Lorenzano <[hidden email]> 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 <[hidden email]> wrote:
>
> Esteban Lorenzano <[hidden email]> 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




Reply | Threaded
Open this post in threaded view
|

Re: [Pharo-Users] Symbolic links

Esteban A. Maringolo
2016-04-21 3:43 GMT-03:00 [hidden email] <[hidden email]>:
> In Windows, there are junctions, which are more or less equivalent.
>
> https://msdn.microsoft.com/en-us/library/windows/desktop/aa365006(v=vs.85).aspx

Yeap, I use it with this tool.

http://schinagl.priv.at/nt/hardlinkshellext/linkshellextension.html

Esteban A. Maringolo

Reply | Threaded
Open this post in threaded view
|

Re: [Pharo-Users] Symbolic links

stepharo
In reply to this post by Valentin Ryckewaert
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