<div dir="ltr">Hi Alistair,<div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 9, 2018 at 1:37 AM, 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> <br>
Hi Eliot,<br>
<div><div class="h5"><br>
On Wed, 8 Aug 2018 at 21:31, Eliot Miranda <<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>> wrote:<br>
><br>
><br>
> Hi Alistair,<br>
><br>
> On Sun, Aug 5, 2018 at 1:02 PM, Alistair Grant <<a href="mailto:akgrant0710@gmail.com">akgrant0710@gmail.com</a>> wrote:<br>
>><br>
>><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>
><br>
><br>
> 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).<br>
<br>
</div></div>Wouldn't it  be better for sqFileStdioHandlesInto to flag the<br>
primitive as failing itself as it could then provide a reason, e.g.<br>
primitiveFailFor or primitiveFailForOSError? (the platform support<br>
file is already doing this in other support routines).<br>
<span class=""><br>
<br>
> 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<br>
><br>
> P.S> I'm specifically looking for code to implement testing directory writability in Squeak.<br>
<br>
</span>OK, just a warning in advance: The code (VM and image) works fine on<br>
Linux and Windows.  I didn't know about the Mac file encoding quirks<br>
until recently, so need to change the plugin to work properly on Mac<br>
OS.  But I haven't got the VM to compile on my Mac virtualbox machine,<br>
so the changes are still local to my PC.  This won't affect you unless<br>
you've got non-ascii characters in your file names.  I should have<br>
fixed this by now, but the problems compiling on Mac have frustrated<br>
me, and I've had very little time (personal reasons).<br></blockquote><div><br></div><div>I develop on the Mac so feel free to email me a change set and tests (e.g. just doit in a workspace) and IO can test for you.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
The main repository for the image side file attributes code is at:<br>
<a href="https://github.com/akgrant43/pharo/tree/21368-Integrate-FileAttributesPlugin" rel="noreferrer" target="_blank">https://github.com/akgrant43/<wbr>pharo/tree/21368-Integrate-<wbr>FileAttributesPlugin</a>.<br></blockquote><div><br></div><div>OK, I'll see if I can grab this wen I have time. Today is taken :-)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
If you're not comfortable with git I think figuring out the changes<br>
will be difficult.  I've got a .cs from a slightly earlier revision<br>
which I can email you - probably directly, it's 93Kb.<br>
<br>
I'll try and put together a change set which just includes enough code<br>
to get file attributes.<br></blockquote><div><br></div><div>I've got myself going.  I have the R_OK, W_OK, E_OK accessors in place so don't need source code.  I do suggest however that primitiveFileAttribute would be nicer to use if it took its arguments in reverse order.  i.e.</div><div><br></div><div>    attribute: attributeNumber forPath: path</div><div><br></div><div>is less clumsy than</div><div><br></div><div>    attributeForPath: path numbered: attributeNumber</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Any other questions, of course please let me know.<br>
<br>
Cheers,<br>
Alistair<br>
</blockquote></div><br><br><div class="gmail_signature" data-smartmail="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>