file locking primitive

Tim Rowledge tim at sumeru.stanford.edu
Sat Jan 3 03:53:58 UTC 2004


Julian Fitzell <julian at beta4.com> wrote:

> This has come up before but we need the file locking primitive in Squeak 
> to support our work in OmniBase.  There has been enough interest in this 
> in the past that I think it's worthwhile coming up with a primitive 
> interface that is implementable in all the common VMs.
OK, first, I don't think that is possible. Just for one case RISC OS
doesn't support locking of parts of a file. That may not worry you too
much given the niche nature of RISC OS but it does point out the
important aspect of platform portability - your code shouldn't cause
trouble if a platform cannot support it.

So, take an extra few moments to think about the issue from this
respect. You might also consider the possibility of providing a common
Sq side api but a variety of platform side apis. We can do this fairly
simply via platform specific VM plugins. I'd strongly recommend NOT
adding this to the generic FilePlugin - for a start that particular vile
monstrosity needs eviscerating with prejudice. It doesn't even have a
decent way to find out if a file exists for goodness sake.


> These questions are based mainly on ignorance about how Squeak deals 
> with the file descriptors, etc.  Any pointers on how to get the FD from 
> the primitive or comments on the correct interface for the primitive 
> would be much appreciated.
You can't get a file descriptor as such; the file doohickey bytearray
contains the structure specified in
platforms/cross/plugins/fileplugin/fileplugin.h and you could read from
that _in your  primitive_. Just include the .h file and away you go.
Please don't try to extract it in Squeak. You shouldn't depend on such
things. Apart from anything else maybe someday soon somebody will get
annoyed enough to gut that foul fileplugin like a dawg and spread its
entrails across the landscape in the manner it deserves.


tim
--
Tim Rowledge, tim at sumeru.stanford.edu, http://sumeru.stanford.edu/tim
Make it right before you make it faster.



More information about the Squeak-dev mailing list