[SAGA-RG] Semantics of the ns_entry constructor

Hartmut Kaiser hkaiser at cct.lsu.edu
Mon Aug 17 07:31:53 CDT 2009


> > >If the above works, I don't see why
> > >
> > >  saga::file::entry e (u);
> > >
> > >should not work.  Or am I missing something?  The same then
> > >also holds for the open methods - the origin of Matijs'
> > >complain.
> >
> > It is a major semantics change. If you do that, all methods in the
> > ns_entry implementations now have to consider the possibility that
> > the entry in fact is a directory, whereas earlier they could just
> > be hidden by ns_directory implementations.
> 
> But yes, that is how it is supposed to work, IMHO.  For
> example, the spec states what happens on entry.copy() if the
> entry happens to be a directory.  And similar for other
> calls on entry.
> 
> > Also, I think it is confusing
> > that you can have a ns_entry object that represents a directory but
> cannot
> > be casted to a ns_directory. Note that I don't have an issue with the
> > change in the ns_directory.open method, only with the change in the
> ns_entry
> > constructor which, being a constructor, cannot deliver a
> ns_directory.
> 
> No, it does not deliver an ns_directory.  The following
> would *not* work:
> 
>   saga::url u ("file://localhost/etc/");
>   saga::file::dir * f = new saga::file::entry (u);
> 
> That would be technically impossible I think.
> But (again) the following should work:
> 
>   saga::url u ("file://localhost/etc/");
>   saga::file::entry * e = new saga::file::entry (u);
> 
> I still don't see a reason why that should be invalid.
> Matijs' use case seems very valid to me:
> 
>   saga::url u ("file://localhost/etc/");
>   saga::file::entry * e = new saga::file::entry (u);
> 
>   if ( e->is_dir () )
>   {
>     saga::file::dir * f = new saga::file::directory (u);
>   }

What should be the outcome of the following:

saga::url u ("file://localhost/etc/");
saga::file::entry e(u);
if (e.get_type() == saga::object::File)
   cout << "e is an entry";
else if (e.get_type() == saga::object::Directory))
   cout << "e is a directory";

? IOW, what's the type of the created object? I think in our implementation
it will report to be a directory, actually.

Regards Hartmut





More information about the saga-rg mailing list