Re: More on file methods
"Mark Hahn" <[email protected]>
| Newsgroups | gmane.comp.lang.prothon.user |
|---|---|
| Message-ID | <[email protected]> |
Mukhsein Johari wrote:
> Hi all, sorry for picking on things but I think it
> would be better to keep the APIs small and consistent.
Pick away. That is your job. :-)
> Right now the file and dir interface is too large,
> IMHO.
> ----------------
> File.move(dir) # move File to location "dir"
> (Dir object), not for renaming
> ----------------
>
> What about making links (symbolic and hard)?
Prothon uses Apache Runtime Library (APR) and links weren't available in the
APR but unix permissions were. We could bug the Apache folks or update the
APR ourselves. I don't know linux/unix so someone else would have to do it.
> -----------------
> File.setUPerms(uperms = 0x600) # sets unix
> permissions
> File.setAttrs(readOnly = None, executable = None,
> hidden = None) # setAttrs will set an
> # attribute to True or False if specified as an
> argument. Otherwise the attribute is
> # left unchanged.
> File.modTime() # returns modification
> DateTime object
> File.setModTime(time) # set modification time to
> time DateTime object
> -----------------
>
> Can we not consolidate all this to normal attribute
> access?
>
> myfile = File('/somedir/somefile.txt', '')
>
> myfile.modTime = myDateTimeObj (write attr)
> myfile.modTime (read attr)
>
> Read only attrs, of course will give exceptions when
> you try to assign a value. (eg. size)
>
> Also, we need a 'cross-platform' way to set read-only,
> executable etc. attrs. In unix it's done very
> differently to windows. Read only would set the uperms
> on unix. (it bitwise or's the uperms)
I agree. How about using properties? I just added the properties feauture
to Prothon recently and have not documented it yet or used it anywhere. If
everyone agrees I'll make file properties a to-do item.
I'll be documenting properties in the tutorial today or tomorrow.