<div dir="ltr">Hi Alistair,<div class="gmail_extra"><br><div class="gmail_quote">On Sun, Aug 5, 2018 at 1:02 PM, Alistair Grant <span dir="ltr"><<a href="mailto:akgrant0710@gmail.com" target="_blank">akgrant0710@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"> <br>
Hi Everyone,<br>
<br>
FilePlugin>><wbr>primitiveFileStdioHandles is responsible for opening stdio<br>
in the VM.  The basic behaviour is to call sqFileStdioHandlesInto()<br>
which does the actual work and returns a mask indicating which streams<br>
were successfully opened (stdin, stdout, stderr).<br>
<br>
However primitiveFileStdioHandles regards a mask of 0, i.e. no files<br>
available, as a primitive failure:<br>
<br>
<br>
sHFAfn ~= 0 ifTrue:<br>
    [(self cCode: ' ((sqInt (*)(void))sHFAfn)()' inSmalltalk: [true]) ifFalse:<br>
        [^interpreterProxy primitiveFailFor: PrimErrUnsupported]].<br>
self cCode: '' inSmalltalk: [fileRecords := Array new: 3].<br>
validMask := self sqFileStdioHandlesInto: fileRecords.<br>
validMask = 0 ifTrue:<br>
    [^interpreterProxy primitiveFailFor: PrimErrUnsupported].<br>
<br>
<br>
This doesn't cause a problem in squeak since all primitive errors are<br>
handled by simply assuming that the stdio files can't be opened and<br>
ignoring any other errors.<br>
<br>
Pharo currently raises an unhandled exception.<br>
<br>
On Windows not having stdio available is a normal condition, so<br>
I think the correct behaviour is for the primitive to succeed, but<br>
return an array of 3 nils, i.e. successfully determined that none of the<br>
stdio files are available (this is effectively what happens in the<br>
Squeak image anyway).<br>
<br>
It would then mean that a primitive failure can be treated as something<br>
going wrong, rather than the normal (on Windows) situation of no stdio<br>
files being available.<br>
<br>
The other (minor) benefit is that at the moment there are two situations<br>
in which the primitive fails with PrimErrUnsupported: sHFAfn ~= 0 and<br>
validMask = 0.  This change would make it easier to interpret the<br>
failure.<br>
<br>
Any objections?<br></blockquote><div><br></div><div>No, but I think the right thing to do is to fail if  sqFileStdioHandlesInto answers a value less than zero.  That would;d still allow the subsystem to communicate some serious error, while allowing the system also to report that no streams are available (e.g. when not attached to a console).</div><div><br></div><div>BTW, is there any image level source code available for accessing the FileAttributesPlugin's primitives?  This is lazy of me, but if there is could you email me a pointer to the code or the code itself asap?  TIA</div><div><br></div><div>P.S> I'm specifically looking for code to implement testing directory writability in Squeak.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
<br>
Thanks,<br>
Alistair<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div>
</div></div>