Boost logo

Boost :

From: Jeff Garland (jeff_at_[hidden])
Date: 2005-03-19 21:15:08


I'm writing a small program with filesystem and I needed to check for symbolic
links so I can avoid processing them. I noticed the symbolic_link_exists
method and, like all good programmers, didn't read the docs b/c I was sure it
didn't do what I needed. So I set about writing a function that would and
when I looked at the filesystem implementation I realized I was wrong. I was
thinking that symbolic_link_exits would check that a symbolic link points to a
valid file -- essentially following the symlink. Any reason why this funtion
isn't called is_symlink to match the is_directory call?

Also, in the code I'm writing I need to only process regular files. So it
would be nice to write:

if (is_file(my_path)) {

  //do stuff
}

where is_file is defined as follows:
// equivalent of if (-d path) in perl
// returns !is_directory(p) && !is_symlink(p);
bool is_file(fs::path p);

Or maybe it could be is_regular_file or is_plain_file if we want to be
verbose. Seems like this would be handy to have in the filesystem lib. I can
probably be talked into supplying patches ;-)

Thoughts?

Jeff


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk