Boost logo

Boost :

From: jan_langer (jan_at_[hidden])
Date: 2002-02-23 13:30:32

--- In boost_at_y..., "Jeff Garland" <jeff_at_c...> wrote:
> So put another way, how does the proposal support the equivalent of
this perl
> code?
> # delete the files from a given directory, but not the
> opendir(MYDIR, "/usr/junk"); #open handle to a directory path
> foreach($name = readdir(MYDIR)) #iterator in perl gives all files
> directories
> {
> if (-f $name) { #test if the 'path' is a file or directory
> unlink($name); #delete the file
> }
> }

for (dir_it i ("/usr/junk"); i != dir_it (); ++i)
  if (!get <is_directory> (i))
    remove (compose ("/usr/junk", *i));

and this does already work if you take the remove from std:: and
define compose as follows (actually as basic_string template)

std::string compose (std::string const &dirpath, std::string const
  return dirpath + '/' + path;

Boost list run by bdawes at, gregod at, cpdaniel at, john at