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

"Mark Hahn" <[email protected]>
Newsgroups gmane.comp.lang.prothon.user
Message-ID <[email protected]>
Mukhsein Johari wrote:
> I was reading the File and Dir objects. It's pretty
> nice overall. Just a few questions:
>
> As per the subject, when does exists?() return False?

When the actually file or directory the path refers to does not exist.

> When you instantiate the File object, it implicitly
> means it exists, right?

No.  The File and Dir objects can be created without opening files or
creating directories.  This is different than Python.  For a File you leave
the mode string empty to mean create the object without opening the file.
The Dir constructor never creates a directory.  You have to use Dir.make()
to create a directory.

> I'm just wondering when this
> would be used.

    # make sure directory exists before using
     if not dir.exists?():
          dir.make()

> Shouldn't size() be fully recursive? Otherwise it
> might be misleading to users. Of course, this could
> take awhile if the dir is large.

This was just a practical decision.  I could be talked into making it
recursive.  My thinking was that you could add code to make it recursive
yourself.

Comments?  Votes?
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.