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
directories...
> opendir(MYDIR, "/usr/junk"); #open handle to a directory path
/usr/junk
> foreach($name = readdir(MYDIR)) #iterator in perl gives all files
and
> 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
&path)
{
  return dirpath + '/' + path;
}


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