cheers -ben
>
> and the perror()/strerror_r() messages are locale-specific:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_03>
> I would like to hear more ideas.
>
> > Sent: Wednesday, March 21, 2018 at 7:08 AM
> > From: "Alistair Grant" <
akgrant0710@gmail.com>
> > To: "Squeak Virtual Machine Development Discussion" <
vm-dev@lists.squeakfoundation.org>
> > Subject: Re: [Vm-dev] [PATCH] added FilePlugin error code lookup function
> >
> >
> > Hi Monty,
> >
> > The VM has a primitive failure that allows the OS error to be
> > returned: #primitiveFailForOSError:
> >
> > Why not simply return the OS error and allow the image to deal with it?
> >
> > Cheers,
> > Alistair
> >
> >
> >
> > On 21 March 2018 at 07:52, monty <
monty2@programmer.net> wrote:
> > >
> > >
> > > +enum {
> > > + SQ_FILE_ERROR,
> > > + SQ_FILE_PERMISSION_ERROR,
> > > + SQ_FILE_ALREADY_EXISTS_ERROR,
> > > + SQ_FILE_DOES_NOT_EXIST_ERROR,
> > > + SQ_FILE_RESOURCE_LIMIT_ERROR,
> > > + SQ_FILE_INVALID_OPERATION_ERROR,
> > > + SQ_FILE_IO_ERROR,
> > > + SQ_FILE_BAD_HANDLE_ERROR,
> > > + SQ_FILE_IS_DIRECTORY_ERROR,
> > > + SQ_FILE_IS_NOT_DIRECTORY_ERROR,
> > > + SQ_FILE_INVALID_NAME_ERROR,
> > > + SQ_FILE_IN_PROGRESS_ERROR
> > > +};
> > >
> > > +
> > > +sqInt
> > > +sqFileErrorCodeFromSystemErrorCode(sqInt errorCode)
> > > +{
> > > + /* A switch statement is avoided, since some error codes, like EAGAIN/EWOULDBLOCK, can
> > > + overlap, and EINTR is not propagated as SQ_FILE_IN_PROGRESS_ERROR, since it should be
> > > + handled internally where possible and because only certain operations can be safely
> > > + reattempted after failing with EINTR
> > > + */
> > > + if (errorCode == EACCES
> > > + || errorCode == EPERM
> > > + || errorCode == EROFS)
> > > + return SQ_FILE_PERMISSION_ERROR;
> > > + else if (errorCode == EEXIST)
> > > + return SQ_FILE_ALREADY_EXISTS_ERROR;
> > > + else if (errorCode == ENOENT
> > > + || errorCode == ENODEV
> > > + || errorCode == ENXIO)
> > > + return SQ_FILE_DOES_NOT_EXIST_ERROR;
> > > + else if (errorCode == EDQUOT
> > > + || errorCode == EFBIG
> > > + || errorCode == EMFILE
> > > + || errorCode == EMLINK
> > > + || errorCode == ENFILE
> > > + || errorCode == ENOLCK