Login  Register

Re: Streams and FileDialog in Pharo 6 and 7

Posted by Sven Van Caekenberghe-2 on Sep 06, 2018; 7:57pm
URL: https://forum.world.st/Streams-and-FileDialog-in-Pharo-6-and-7-tp5084352p5084355.html



> On 6 Sep 2018, at 21:37, Torsten Bergmann <[hidden email]> wrote:
>
> Hi,
>
> A question to those who worked on the new streams for Pharo 7:
>
>
> In PHARO 6 I used the following expression to open a file dialog and let the user choose
> a binary file:
>
>    s := UITheme builder fileOpen: 'Choose a file' extensions: #('exe').
>
> This returned
> - either nil (when file dialog was canceled)
> - a "MultiByteFileStream" instance when a file was selected
>
> The MultiByteFileStream instance already had the name of the file (= full path) and I was
> able to query it for further use:
>
> s := UITheme builder fileOpen: 'Choose a file' extensions: #('exe').
> s name inspect
>
> (for instance to display which file is processed in a window by showing the full path)
>
>
>
> Now in PHARO 7 same expression returns an instance of ZnCharacterReadStream (as MultiByteFileStream
> is deprecated):
>
> s := UITheme builder fileOpen: 'Choose a file' extensions: #('exe').
>
> and  ZnCharacterReadStream  does not understand #name - and in fact the info about the name is
> totally lost/not available. To me this looks missing/broken.
>
> So what is the recommended way in Pharo 7 to open a file dialog, let the use choose a file
> and get a file stream but also the name? IMHO this is either broken or missing...
>
> Thanks
> T.

It should return a FileReference, not an open stream. I believe there are methods that do that.

But that is an incompatible API change (same selector, different return type). So hard to decide.