Discussion:
recursive FILE_SEARCH in a symbolic link ?
(too old to reply)
nata
2010-06-17 18:28:20 UTC
Permalink
Hi guys,

I have a directory containing some symbolic links. When I try to do a
recursive file search, IDL does not take into account the links.
Do you know how can I do this search, through all the links ?
I want to avoid Windows errors so I need an standard solution...

Thanks in advance,
nata
jdehls
2010-06-17 19:47:43 UTC
Permalink
Post by nata
Hi guys,
I have a directory containing some symbolic links. When I try to do a
recursive file search, IDL does not take into account the links.
Do you know how can I do this search, through all the links ?
I want to avoid Windows errors so I need an standard solution...
Thanks in advance,
nata
You say you are working in Windows? How did you create the symbolic
links? Are they symbolic links, hard links or directory junctions? I
think what you want to do is create directory junctions using the
mklink command.
http://www.maxi-pedia.com/mklink
nata
2010-06-17 20:56:33 UTC
Permalink
I'm working in Linux...
What I mean is that I do not want a code that does not work in
Windows, that's all.

My symbolic links are links to directories created using the command
ln -s target link_name

nata
Heinz Stege
2010-06-18 01:03:42 UTC
Permalink
Post by nata
I'm working in Linux...
What I mean is that I do not want a code that does not work in
Windows, that's all.
My symbolic links are links to directories created using the command
ln -s target link_name
nata
Hello nata,

I made a test on Windows. I created some links on a NTFS drive with
the cygwin ln-command:

$ ln text.txt hardlink_to_file.txt
$ ln -s text.txt softlink_to_file.txt
$ ln -s ../folder2 softlink_to_folder

And what shall I say, FILE_SEARCH finds them all. Here are the
results:

IDL> f=file_search('test\folder','*')
IDL> print,f,format='(a)'
test\folder\hardlink_to_file.txt
test\folder\softlink_to_file.txt.lnk
test\folder\softlink_to_folder.lnk
test\folder\test.txt
IDL> print,!version
{ x86 Win32 Windows Microsoft Windows 7.1.2 Oct 28 2009 32
64}

Note that Windows added the extension ".lnk" to the soft links.

HTH, Heinz
nata
2010-06-18 02:13:29 UTC
Permalink
Hi Heinz,

Thank you for your reply.
My problem is using symlinks in Linux and trying to do the recursive
search through them.
More details:

My folder contains 4 symlinks and I'm doing the search in the "base"
folder.
test/symlink-1 -> data/dir1
test/symlink-2 -> data/dir2
test/symlink-3 -> data/dir3
test/symlink-4 -> data/dir4


I do, file_search('test','*') and the result is nothing. data/dir1
contains 10 files, data/dir2 contains 10 files more, etc.
If I do file_search('test/symlink-1') the result is correct but the
recursive search does not work if I use the test directory. That's
what I'm trying to do...

Thanks for your help,
nata
Maarten
2010-06-18 08:37:23 UTC
Permalink
Post by nata
Hi Heinz,
Thank you for your reply.
My problem is using symlinks in Linux and trying to do the recursive
search through them.
This is documented in the file_search help. To avoid infinite loops,
file_search will not search within symlinks to directories.

You can recreate the tree, and populate the tree with symlinks to the
files. Just make sure that all directories are real. Another
alternative is to just don't do Windows, and use the unix find tool
through spawn to find your stuff.

Best,

Maarten
Heinz Stege
2010-06-18 12:06:32 UTC
Permalink
Post by Maarten
Post by nata
Hi Heinz,
Thank you for your reply.
My problem is using symlinks in Linux and trying to do the recursive
search through them.
This is documented in the file_search help. To avoid infinite loops,
file_search will not search within symlinks to directories.
Yes, I was too careless last night. In reading manuals ;-( and in
performing tests. This morning I put a file into the folder, which is
the target of a symbolic link. Corresponding to the manual file_search
does not see this file (in the symbolic link). It does not find the
file in both syntaxes, the recursive and the standard one. So the
results on Linux and on Windows are the same. At least for the
recursive search.

By the way cygwin does not to create real symbolic links. It simulates
them by using Windows-shortcuts.

Heinz
nata
2010-06-18 12:55:42 UTC
Permalink
Thank you guys,

Why I didn't find this explanation in the documentation ?
Anyway, I have to change some directories....
Have a great day,
nata

Continue reading on narkive:
Search results for 'recursive FILE_SEARCH in a symbolic link ?' (Questions and Answers)
6
replies
examples of math trivias?
started 2006-12-04 18:54:22 UTC
mathematics
Loading...