Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2011-02

Handling recursive symlinks in Linux

3 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

brian

I'm trying to convert a Delphi console-mode program which needs to walk directory trees to FP **and Linux** - is there a standard way to detect and handle recursive symlinks, if the user has been daft enough to create them?

Thanks,

Brian.

Reply by email

Michael Van Canneyt
to brian
brian wrote
I'm trying to convert a Delphi console-mode program which needs to walk directory trees to FP **and Linux** - is there a standard way to detect and handle recursive symlinks, if the user has been daft enough to create them?

You can use faSymLink in FindFirst/FindNext to detect symbolic links (this works on windows as well) and then use fpReadLink (unit baseunix) to see where the link leads too.

Michael.

Reply by email

Jonas Maebe
to brian: I'm trying to convert a Delphi console-mode program which needs to walk directory trees…
brian wrote
I'm trying to convert a Delphi console-mode program which needs to walk directory trees to FP **and Linux** - is there a standard way to detect and handle recursive symlinks, if the user has been daft enough to create them?

Many programs handle this by following symlinks only to a certain maximum depth. E.g., they print an error if they have followed 16 or more symlinks already. An alternative is to keep track of every directory you have traversed (or are traversing) already, and to skipping symlinks pointing to such directories.

Jonas

Reply by email