← Back to team overview

dolfin team mailing list archive

Re: [Branch ~dolfin-core/dolfin/main] Rev 4998: Fix bug in File.cpp when creating directories.

 

On Tue, Aug 17, 2010 at 11:24:37AM +0100, Garth N. Wells wrote:
> On Tue, 2010-08-17 at 12:12 +0200, Anders Logg wrote:
> > On Tue, Aug 17, 2010 at 09:46:22AM -0000, noreply@xxxxxxxxxxxxx wrote:
> >
> > >  File::File(const std::string filename, std::string encoding)
> > >  {
> > > -  // Get directory and extension
> > > +  // Get file path and extension
> > >    const boost::filesystem::path path(filename);
> > > -  const boost::filesystem::path directory = path.parent_path();
> > > -  const std::string extension = path.extension();
> > > +  const std::string extension = boost::filesystem::extension(path);
> >
> > Is there a difference between the member function and the free
> > function?
> >
> > > -  // Create directory if necessary
> > > -  if (!is_directory(directory))
> > > +  // Create directory if we have a parent path
> > > +  if ( path.has_parent_path() )
> > >    {
> > > +    const boost::filesystem::path directory = path.parent_path();
> > >      cout << "Creating directory \"" << directory.string() << "\"." << endl;
> > >      boost::filesystem::create_directories(directory);
> > >    }
> >
> > What was the problem here?
> >
>
> Seg fault.
>
>   if (!is_directory(directory))
>
> seg faults if there is no directory.

Strange, I interpreted this as returning false is there is no
directory.

> This is why we need to get the buildbots green again ;)

I know. :-)

--
Anders

Attachment: signature.asc
Description: Digital signature


References