Re: Re: When is File/Dir.exists?() false?

"Mark Hahn" <[email protected]>
Newsgroups gmane.comp.lang.prothon.user
Message-ID <[email protected]>
"Mukhsein Johari" <[email protected]> wrote

> So...if the file is non-existent, what actually
> happens when you do:
>
> myFileObject.read() and write()? close()?

You get an exception.

> And what about accessing file attributes?

No problem.

> Once you have instantiated the dir obj, can you change
> the path of the dir object?

No, all these objects are immutable.  That is why Dir.rename() &
File.rename() return a new object.

> >      if not dir.exists?():
> >           dir.make()
>
> if it gives exception (say you do not have permission
> to make that dir) what do you do with the dir object?
> Destroy it and make another?

Just ignore it.  What do you do with "y" after you say "str = x + y " ?

> I'm feeling a bit uneasy about file and dir objects
> that don't refer to existing files and dirs. I can't
> put my finger on why though. It just doesn't seem
> useful to me.

I'm sorry.  How else could I have the method "delete()" if an object could
only exist when it's file system equivalent existed.  Don't forget that I'm
attempting something new here.  Not even Java has a true object-oriented
file system.

> Could you show a simple use-case?

I already did.  If you have an alternate idea for how to do this, I'd love
to hear it.  The one big stumbling block I'm thinking of at this moment is
what to do on Dir.delete().  The dir object cannot dissapear.  Only the
garbage collector is allowed to make objects dissapear.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.