Boost logo

Boost Users :

Subject: Re: [Boost-users] (newbie) is_regular_file vs. symlinks in boost::filesystem ?
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2012-09-18 00:14:18


AMDG

On 09/17/2012 01:34 PM, Christian Convey wrote:
> I'm writing code that takes a file pathname as a command-line
> argument. My program doesn't care whether the pathname is for a
> regular file, or if it's a symlink that ultimately leads to a regular
> file.
>
> This seems like such a common usage pattern that I would have expected
> Boost to have a built-in solution to this problem. But I don't see
> one. At the moment it looks like I'll have to write code like this:
>
> my_path = argv[1];
>
> while (my_path is a symlink) {
> set my_path to the target of the symlink;
> error out of a cycle or excessive indirection is detected;
> }
>
> if (! is_regualr_file( my_path )) {
> tell user there's a problem;
> }
>
> Do I really need to write code like this?
>

According to the current (1.51) documentation, no.
is_regular_file should already handle this.

In Christ,
Steven Watanabe


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net