I hope I'm not asking a stupid question... If I symlink a directory, is symlink considered as directory in R? If so, why `dir.exists` returns FALSE on directory? I understand symlink is essentially a file, but functionally a symlink to directory is no different to the directory itself, but a directory is also essentially a file. Is there any way that allow me to check if a symlink is linked to directory in base R, like `dir.exists(..., symlink_ok = TRUE)`? Thanks, Dipterix
dir.exists returns FALSE on Symlink directory
6 messages · Ivan Krylov, Stephen H. Dawson, DSL, Serguei Sokol +1 more
? Mon, 26 Jun 2023 10:26:07 -0400 Dipterix Wang <dipterix.wang at gmail.com> ?????:
If I symlink a directory, is symlink considered as directory in R?
It seems to work, at least on GNU/Linux:
# (on this system, /var/lock is a symbolic link pointing to /run/lock/)
system('ls -l /var/lock')
# lrwxrwxrwx 1 root root <...> /var/lock -> /run/lock
dir.exists('/var/lock')
# [1] TRUE
If so, why `dir.exists` returns FALSE on directory?
Which operating system? Judging by your User-Agent, it must be some version of macOS. Can you provide the output of `ls -l` on the symbolic link?
Best regards, Ivan
It sounds like either R as a whole or the R session does not have permission to view the directory. *Stephen Dawson, DSL* /Executive Strategy Consultant/ Business & Technology +1 (865) 804-3454 http://www.shdawson.com
On 6/26/23 11:07, Ivan Krylov wrote:
? Mon, 26 Jun 2023 10:26:07 -0400 Dipterix Wang <dipterix.wang at gmail.com> ?????:
If I symlink a directory, is symlink considered as directory in R?
It seems to work, at least on GNU/Linux:
# (on this system, /var/lock is a symbolic link pointing to /run/lock/)
system('ls -l /var/lock')
# lrwxrwxrwx 1 root root <...> /var/lock -> /run/lock
dir.exists('/var/lock')
# [1] TRUE
If so, why `dir.exists` returns FALSE on directory?
Which operating system? Judging by your User-Agent, it must be some version of macOS. Can you provide the output of `ls -l` on the symbolic link?
Le 26/06/2023 ? 16:26, Dipterix Wang a ?crit?:
I hope I'm not asking a stupid question...
Many think that there is no such thing as "stupid question". However, this one looks more appropriate for r-help list, does not it?
If I symlink a directory, is symlink considered as directory in R? If so, why `dir.exists` returns FALSE on directory? I understand symlink is essentially a file, but functionally a symlink to directory is no different to the directory itself, but a directory is also essentially a file. Is there any way that allow me to check if a symlink is linked to directory in base R, like `dir.exists(..., symlink_ok = TRUE)`?
What about :
dir.exists(Sys.readlink("your_link"))
?
Best,
Serguei.
Thanks, Dipterix
______________________________________________ R-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Serguei Sokol Ingenieur de recherche INRAE Cellule Math?matiques TBI, INSA/INRAE UMR 792, INSA/CNRS UMR 5504 135 Avenue de Rangueil 31077 Toulouse Cedex 04 tel: +33 5 61 55 98 49 email: sokol at insa-toulouse.fr https://www.toulouse-biotechnology-institute.fr/en/plateformes-plateaux/cellule-mathematiques/
Le 26/06/2023 ? 17:17, Serguei Sokol a ?crit?:
Le 26/06/2023 ? 16:26, Dipterix Wang a ?crit?:
I hope I'm not asking a stupid question...
Many think that there is no such thing as "stupid question". However, this one looks more appropriate for r-help list, does not it?
? If I symlink a directory, is symlink considered as directory in R? If so, why `dir.exists` returns FALSE on directory? I understand symlink is essentially a file, but functionally a symlink to directory is no different to the directory itself, but a directory is also essentially a file. Is there any way that allow me to check if a symlink is linked to directory in base R, like `dir.exists(..., symlink_ok = TRUE)`?
What about :
dir.exists(Sys.readlink("your_link"))
Or even better:
file_test("-d", "your_real_dir_or_simlink_to_dir")
which returns TRUE for both a real dir and a simlink to a dir.
Best,
Serguei.
? Best, Serguei.
Thanks, Dipterix
______________________________________________ R-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Serguei Sokol Ingenieur de recherche INRAE Cellule Math?matiques TBI, INSA/INRAE UMR 792, INSA/CNRS UMR 5504 135 Avenue de Rangueil 31077 Toulouse Cedex 04 tel: +33 5 61 55 98 49 email: sokol at insa-toulouse.fr https://www.toulouse-biotechnology-institute.fr/en/plateformes-plateaux/cellule-mathematiques/
Thanks! I think Sys.readlink resolved my issue. Indeed I found a permission issue. I will post my questions to r-help next time. Best, Dipterix
On Jun 26, 2023, at 11:17 AM, Serguei Sokol <sokol at insa-toulouse.fr> wrote: Le 26/06/2023 ? 16:26, Dipterix Wang a ?crit :
I hope I'm not asking a stupid question...
Many think that there is no such thing as "stupid question". However, this one looks more appropriate for r-help list, does not it?
If I symlink a directory, is symlink considered as directory in R? If so, why `dir.exists` returns FALSE on directory? I understand symlink is essentially a file, but functionally a symlink to directory is no different to the directory itself, but a directory is also essentially a file. Is there any way that allow me to check if a symlink is linked to directory in base R, like `dir.exists(..., symlink_ok = TRUE)`?
What about :
dir.exists(Sys.readlink("your_link"))
?
Best,
Serguei.
Thanks, Dipterix
______________________________________________ R-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
-- Serguei Sokol Ingenieur de recherche INRAE Cellule Math?matiques TBI, INSA/INRAE UMR 792, INSA/CNRS UMR 5504 135 Avenue de Rangueil 31077 Toulouse Cedex 04 tel: +33 5 61 55 98 49 email: sokol at insa-toulouse.fr https://www.toulouse-biotechnology-institute.fr/en/plateformes-plateaux/cellule-mathematiques/